JavaScript Tutorial For Beginners #21 - Variable Scope

preview_player
Показать описание
Hey all, this JavaScript tutorial for beginners will introduce the concept of variable scope. Variables can have either global or local scope.

A global variable is initialized at the 'top-level' of your document, and can be used anywhere within your document after it has been declared. A local variable has only local scope, and can only be used within the function in which it was initialized.

As always, fire away with any questions :)

========== JavaScript for Beginners Playlist ==========

========== CSS for Beginners Playlist ==========

========== HTML for Beginners Playlist ==========

========== The Net Ninja ============

========== Social Links ==========

Рекомендации по теме
Комментарии
Автор

Thank you for explanation of variable scope here, none of others talks about it any where in there tutorial.

renukagargicollege
Автор

I already encounter this "function" but in java. And I really don't understand how this "functions" work. I can't understand my profs when they're explaining this. I'm glad I finally got it in my head. Thank you. Valar Morghulis.

sungjinwooman
Автор

As others have already said, you are an absolute god-send. I find your videos so easy to follow

Jack-CS
Автор

Got stuck thinking about this in the previous lesson, thank God you talked about it here!

CalebPendergast
Автор

Watching you or watching the BBC gives the same experience, the classic British accent.

muhammadsiddiqui
Автор

Important Side Note:
If you declare a variable inside a function without Var Keyword then it is a Global Variable.It means you can use that variable anywhere in the code .Hope that helps .Thank you .

muneebmohammedsaleem
Автор

Fantastic explanations. Learning at a boot camp in London. Unfortunately my instructors are shite so fortunately you make up for all my tutors. You sound like a yorkie, my mum is from

vinnym
Автор

So...you creating a variable outside the function, as global, and then change it's value inside the function like you did on this example, does the value of the variable becomes this new value?? In this case, does the value of "average" becomes 9? And equals to "my Result" too??

lucianoilha
Автор

Excellent Video! Question: by pulling average out of the local variable and setting it as a global AND setting it to zero, what does that mean/do to its "initial value"? Or is this just the standard initial value to give? Thanks in advance.

infotainment
Автор

How to know better about recursion? Seriously this thing probably is the hardest material in javascript

radenbagushadiningratsoery
Автор

Do you have any plans In the future to do another vanilla JavaScript series Shaun?

adante
Автор

Is this known as closure if not do you have video explaining closures in JavaScript think they are in functions

skillfulactor
Автор

why and when I use return inside a function.
expect some explanation.

hasanmottaqi
Автор

can u please explain where to put functions and variables a bit better and what the difference between console.log and document.write is

husnainali-gnbo
Автор

Can we say
Last line
logresult(); // as calling function
And why we use this
Anyone can reply 🤗

saikiran-dhxh
Автор

What if I don't use "return average" and just input "var myResult = getAverage(7, 11);"?

JessiePXD
Автор

what do i use this all for you have not told me yet and i watched 20 video's, do I need to watch these to get better insight and working knowledge on the design of webpages?

BadassItalianJew
Автор

2:41 Or it didn't work because you didn't put a semi-colon.

thewebmaster