• Saturday , 28 March 2020

18: Hoisting in JavaScript Explained | What is Hoisting in JavaScript | JavaScript Tutorial

Code Canyon

In this JavaScript tutorial you will learn about hoisting in JavaScript. Hoisting is a word you are very likely to run into at some point when coding JavaScript. Hoisting is a term we use to describe when some of the code is allocated space in the browser before the content is shown on a web page.

Meet Daniel: another Full-Stack developer who can teach you coding fast and free 😀


First of all, thank you for all the support you have given me!

I am really glad to have such an awesome community on my channel. It motivates me to continue creating and uploading content! So thank you!

I am now using Patreon to share improved and updated lesson material, and for a small fee you can access all the material. I have worked hard, and done my best to help you understand what I teach.

I hope you will find it helpful 🙂

Material for this lesson: https://www.patreon.com/posts/javascript-18-19237826

Original source

3d Ocean

Related Posts


  1. Victor Pinedo
    November 26, 2019 at 19:12

    Bro so much thanks for this kind of content, it really helps, get know how things happen it's more important than make it… thanks again, great job man

  2. Sukhamrit Bains
    November 26, 2019 at 19:12

    Bro you're actually a G. Love u man

  3. 1000SUNZZ
    November 26, 2019 at 19:12

    Thanks for all the help man!

  4. SinusDavy
    November 26, 2019 at 19:12

    Finally i got the upsides of anonymous functions. Thank you very much! Your tutorials are truly great.

  5. Moira Walker
    November 26, 2019 at 19:12

    Thanks!! Really clear explenations 🙂

  6. Amir Ali
    November 26, 2019 at 19:12

    excellent explaination! thanks

  7. Márcio Barbosa
    November 26, 2019 at 19:12

    "Before run all the code, the browser first get all declarations
    , hoisting is the name of this process." The most simple explanation ever, thanks!

  8. Amr Nashaat
    November 26, 2019 at 19:12

    thank you for the clear explanation and effort put into these lessons

  9. Umar Raza
    November 26, 2019 at 19:12

    In case of anonymous function, you declared a variable and set it's value equal to an anonymous function. Why hoisting doesn't take place in this case? We have a declartion of a 'variable' having value equal to a function. This variable could have also been hoisted. If not, then why?

  10. Suong Tu
    November 26, 2019 at 19:12

    Your channel subscribers is almost reached 200k. Thank for take time to explaining everything, put lot of effort in every single video.

  11. Adithya Kamath
    November 26, 2019 at 19:12

    You sir earned a subscriber! Brilliant! Thank you!

  12. German Sanchez
    November 26, 2019 at 19:12

    Great class. Thanks.

  13. Samson Taylor
    November 26, 2019 at 19:12

    when assigning a var to an anonymous function, does that var now become a global var? Global var is loaded to the browser….is this correct? I thought the point of using local var and anonymous functions was to avoid loading info into the browser….? Just a little confused on that.

  14. Samson Taylor
    November 26, 2019 at 19:12

    So global variables are loaded in the browser but local is not and the only time you want to use a global is when you need to access the same var at any point in a .js script script like user input? Correct?

  15. Hamdamboy Urunov
    November 26, 2019 at 19:12

    Perennially appreciate, nice explanation:
    Function types:
    – Name function
    – Anonymous function

    – Name function is available defining any part of the source code ( included console log ) as well. Working properly.

    – Anonymous function
    variable name includes function and working well before ( console log etc.)

    * BUT if change position, it cannot work as well. DEFINING FUNCTION is important …

  16. GyrWorker
    November 26, 2019 at 19:12

    I like how you explain things 😉

  17. The God
    November 26, 2019 at 19:12

    bro you move your hands so much, calm the fuck down are you on drugs lol

  18. Gabriel Rodriguez
    November 26, 2019 at 19:12

    Great Explanation cristal clear!!

  19. Sh Nam
    November 26, 2019 at 19:12

    Veryyy well explained, thank u. I hope to see more tutorials from u.

  20. superreverbfreak
    November 26, 2019 at 19:12

    so hoisting hoists up the variable and the name but not the value of the variable? so why does that change when its in a function? if you explained it in the video i apologize but im really trying to understand the dynamics of javascript right now i feel its the only way to grasp it at all….thanks for your knowledge…..edit….is it only because its been given a name?

  21. Fahad Ahmed
    November 26, 2019 at 19:12

    Thanks for the tut! Now I understand what hoisting is. 🙂

  22. David Shook
    November 26, 2019 at 19:12

    what sign language is that?

  23. Lokendra Bohara
    November 26, 2019 at 19:12


  24. Icermi Ribano
    November 26, 2019 at 19:12

    Thank you!! This is very helpful!

  25. Abe TT
    November 26, 2019 at 19:12

    This video was just … :l AWESOME! Thanks.

  26. Pedro Esgueira
    November 26, 2019 at 19:12

    Hi there, thanks for the video. I'm new to coding, just started recently, so allow me any confusion on my side. Could you maybehelp me with the following points: 1) You explained that hoisting puts your code up at the beginning, but MDN (https://developer.mozilla.org/en-US/docs/Glossary/Hoisting) actually refers to hoisting "a strict definition of hoisting suggests that variable and function declarations are physically moved to the top of your code, but this is not in fact what happens. Instead, the variable and function declarations are put into memory during the compile phase, but stay exactly where you typed them in your code." 2) at 9.48 minutes, while the function itself does not get hoisted, it does seem to me one can't escape hoisting to some extent(?): the anonymous function is actually a variable declaration, so if you would console.log(a) instead of console.log(a()) it would still return undefined because the declaration is getting hoisted. It just doesn't in your example because you are asking for its value – which happens to be function – and like you explained values don't get hoisted. Any feedback is appreciated. Thanks!

  27. Manav Sharma
    November 26, 2019 at 19:12

    you are such an amazing teacher. Thank you so much for this amazing tutorial series.

Leave A Comment

You must be logged in to post a comment.