Please enable JavaScript.
Coggle requires JavaScript to display documents.
Javascript
ECMAScript (Hoisting (Only variables using var keyword are…
Javascript
ECMAScript
-
The variable and function declarations are put into memory during the compile phase, but stay exactly where you typed them in your coding
Javascript interpreter performs 2 passes over the code
- First pass all declarations extracted
- Code executed
The result is a result of interpreter is that variable declarations put to the top of their scope
-
When you see a function declaration after it has been called in the code - it still runs because of Hoisting which is how the Javascript interpreter works
-
History
-
Created quickly to stop Microsoft from gaining market dominance of web browsers. Its quick creation later came to be ridiculed for things such as
- automatic semicolon insertion (ASI)
- Automatic type coericion when using common operators like '=='
- lack of block scoping
- lack of classes
- lack of dedicated modularisation capability
- unusual inheritance (prototypical)
Versions
Javascript became ECMA standard in 1997
- From 2015 ECMAScript is named by year e.g ECMAScript 2015
- ECMAScript 1 => First Edition
- ECMAScript 2 => Editorial changes 1998
- ECMAScript 3 => Added regular expressions and try/catch 1999
- ECMAScript 5 => Added strict mode, JSON support, String.tim(), Array.isArray() 2009
- ECMAScript 2015 - added let and const, default parameter values, array.find
- ECMAScript 2016 - added exponential operator and array.prototype.includes
- ECMA Script 2017 - string padding, new object props, async functions, shared memory
- ECMAScript 2018 => rest/spread props, async iterations, Promise.finally()
-
-
-
Change an array of objects to an object of objects:
const getMapFromArray = data => {
data.reduce(( acc, item) => {
acc[item.id] = item;
return acc;
}, {})
);
getMapFromArray(inputFromServer)