This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var promise = new Promise((resolve)=>{ | |
setTimeout(() => { | |
console.log('promise timeout fired'); | |
resolve(42); | |
}, 500); | |
console.log('promise started'); | |
}); | |
promise.then((x) => console.log(x)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function foo(){ | |
var a = 2; | |
function bar(){ | |
console.log( a ); | |
} | |
bar(); // 2 not-closure, regular lexical scope actually | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Each of the following options will create a new empty object: | |
var newObject = {}; // or | |
var newObject = Object.create(null); // or | |
var newObject = new Object(); | |
// four ways in which keys and values can then be assigned to an object | |
// ECMAScript 3 compatible approaches | |
// 1. Dot syntax | |
newObject.someKey = 'Hello World'; // Write properties |