JavaScript Scope

Global execution scope for JavasScript in a web browser should be the window object. Global variables and functions are properties and methods of the window object. These functions and variables are destroyed when the browser is shutdown or the web page closed. When a function is called, a scope chain of variables is created which gives you ordered access to all available … [Read more...]

JavaScript Primitive and Reference Variables

JavaScript has no rules for the type of data that a variable must hold. The type and value can change. JavaScript divides the variables into two major types: Primitive and Reference. Primitive variables are simple atomic pieces of data and Reference variables are objects of multiple values. The five primitive types are: Undefined, Null, Boolean, Number, and String. We … [Read more...]

JavaScript Functions

Functions can't be named eval or arguments JavaScript doesn't care how many arguments are passed in nor about the data types of those arguments. Each function has an arguments object that holds the arguments passed in. You can access the arguments passed with arguments[0], arguments[1], etc. Use arguments.length to find out how many arguments were passed to the … [Read more...]

JavaScript Statements

JavaScript uses the basic statements found in most languages. if/then/else do while while for-in Used to iterate the properties of an object. break Used in a loop to exit the loop immediately and continue at the statement following the loop. continue Used in a loop to exit the loop but executes from the beginning of the loop. This … [Read more...]

JavaScript Equality Operators

Boolean values are converted to numbers before comparisons are made with the equal operator (==) and not equal operator (!=). Comparisons where one operand is a string and the other is a number converts the string to a number first. If one of the operands is an object and not the other then the object is evaluated with the valueOf() function first. null and undefined … [Read more...]