• Sunday , 7 June 2020

JavaScript Tutorial For Beginners #21 – Variable Scope

Code Canyon



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 🙂

SUBSCRIBE TO CHANNEL – https://www.youtube.com/channel/UCW5YeuERMmlnqo4oq8vwUpg?sub_confirmation=1

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

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

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

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

For more front-end development tutorials & to black-belt your coding skills, head over to – https://www.youtube.com/channel/UCW5YeuERMmlnqo4oq8vwUpg or http://thenetninja.co.uk

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

Twitter – @TheNetNinja – https://twitter.com/thenetninjauk

Original source

3d Ocean

Related Posts

10 Comments

  1. Caleb Pendergast
    July 23, 2019 at 02:32

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

  2. skillfulactor09
    July 23, 2019 at 02:32

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

  3. Seán Black
    July 23, 2019 at 02:32

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

  4. Infotainment
    July 23, 2019 at 02:32

    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.

  5. Muneeb mdsaleem
    July 23, 2019 at 02:32

    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 .

  6. Mottaqi
    July 23, 2019 at 02:32

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

  7. The Web Master
    July 23, 2019 at 02:32

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

  8. jessie
    July 23, 2019 at 02:32

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

  9. david rose
    July 23, 2019 at 02:32

    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?

  10. husnain ali
    July 23, 2019 at 02:32

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

Leave A Comment

You must be logged in to post a comment.