17 Variable Hoisting example - JavaScript Tutorial 2018

Опубликовано: 23 Июнь 2017
на канале: Ricky Wahowa
38
0

Full #Javascript #tutorial for #beginners :

http://bizanosa.com/js


Learn HTML, CSS and JavaScript

http://bizanosa.com/sp/learn-html-css...

JavaScript Tutorial 2018




This is a Javascript tutorial from scratch for any beginner. Use the above link to watch the full JS video tutorial..

Next Video:    • 18 Function hoisting example - JavaScript ...  
Previous Video:    • 16 Variable and function hoisting  - JavaS...  

Hi, and welcome back.

So if I come here to Firefox and then open Scratchpad, I already have this typed out here.

So in this case, you’re seeing that I’m calling ‘x’ and ‘x’ has been declared down here.

So if I run this, it'll give me ‘x’ is undefined.

And this is an example you are familiar with because you saw the same thing when we were looking at undefined and reference errors in JavaScript.

So if I run this, ok, this is because I already did run this with ‘x’ up there.

So let me change, let me call ‘y’, and then run this.

Okay.

I also did run ‘y’.

So let's say I do ‘z’ and I change this to ‘z’ and then I run.

Let me close that and then I run.

You'll see it gives us undefined.

So the reason the first time I did ‘x’ and said they showed the values of ‘5’ and ‘10’ is because that is the second time I was running this code.

You know that by the second time I’m running the code, these variables are already stored in the memory of the browser.

So even if I run this a second time, and right now if I run this a second time, it’ll give me the value of ‘z’ as ‘5’ because by now, the value of ‘z’ is already stored in the browser.

So if I run it, let me first of all close this undefined.

And if I run this, it'll give us the value of ‘z’ is equals to ‘5’.

And this is because, the value of ‘z’, by the second time I’m running this code, the value of ‘z’ is a variable that is already stored within the memory of the browser.

So keep that in mind.

Okay.

So we said that functions are also hoisted.

So this is a simple function and I have it commented out.

This is a simple function that adds ‘3’ and ‘4’.

So in the next video, let's look at how this function will get hoisted to the top.

I will see you in that next video.








GET SOCIAL WITH ME:
FACEBOOK:   / rwahowa  
INSTAGRAM:   / rwahowa  
TWITTER:   / rwahowa  
VIMEO: https://vimeo.com/bizanosa/
WEBSITE : http://rwahowa.com


На этой странице сайта вы можете посмотреть видео онлайн 17 Variable Hoisting example - JavaScript Tutorial 2018 длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Ricky Wahowa 23 Июнь 2017, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 38 раз и оно понравилось 0 зрителям. Приятного просмотра!