Curriculum
Course: JavaScript Basic
Login

Curriculum

JavaScript Basic

JSHome

0/216
Text lesson

Warning

Avoid creating global variables unless absolutely necessary.

Your global variables (or functions) can potentially overwrite existing properties or functions of the window object. Likewise, any function, including those of the window object, can overwrite your global variables and functions.

The Lifetime of JavaScript Variables

A JavaScript variable’s lifetime begins when it is declared.

Local (function) variables are deleted once the function finishes executing.

In a web browser, global variables are deleted when the browser window or tab is closed.

Function Arguments

Function arguments (parameters) behave like local variables within functions.