Please enable JavaScript.
Coggle requires JavaScript to display documents.
Javascript (Scope (Lexical Scope, Execution Scope, Scope chain, Outer…
Javascript
-
-
Arrays and operations
array map() method - takes a function param and runs it against each element. returns the new array.
var numbers = [3,4,65,64,2];
var results = numbers.map (function (i){return i *2;} );
array shift() method - returns the cell that it removes from the front of the array. same as pop() in stack datatype in c#.
var passQueue = ["ships","boats","cars"];
var firstElement = passQueue.shift();
//firstElement = "ships"
-
Functions
-
function expressions
//function is stored in a variable
var diff = function doubleMe (a) { return a * 2 ; }
diff(); //execute//fe can also be anonymous like this
var dffi2 = function (a){ return a * 2};Link Title
-
Concepts/Features
Closures - created whenever a function is created. It refers to the function's enclosed references to its surrounding or outer scope. Simply put, when a function is created and maintained alive by assigning to a variable, that function has access to its surrounding environment/scope with the state at the time the function is created.
-
-
JS doesn't have the concept of namespace like in java or c#.
To fake namespace, we create an object container.
Global object is the global namespace perse.
Execution Contect is Created (function):
Variable Environment
Outer Environment
"this" - points to the object where the func is created.
"arguments"
-