Lets learn something everyday.
var m = {};
var a = {id: 1},
b = {id: 2};
m[x] = 'foo';
m[x] = 'bar';
m[x]?
m[y]?
- WeakMap take only object as keys.
- They don't have
size
orclear
method. - They don't have iterartor over
keys
,values
orentries
.
Initialize an array of given length with default values:
Array(3).fill(null); // [null, null, null]
// Fail-soft destructuring with defaults
var [a = 1] = [];
a === 1;
Unlike function declarations, class declarations are not hoisted.
// A class only exists after execution reached its definition and it was evaluated.
// Accessing it beforehand leads to a ReferenceError
new Foo();
class Foo {}
var a = null;
(!a && typeof a === "object"); // true
null is the only primitive value that is "falsy" but that also returns "object" from the typeof check.
Unlike referencing undeclared variables, there is no ReferenceError thrown if you try to access an object property (even on the global window object) that doesn't exist.
Prototypes having data properties is generally considered an anti-pattern, so this just enforces a best practice.
constructor, static methods, prototype methods
spread elements 'expands' an array into its elements, and rest elements collects multiple elements and 'condenses' into a single element.
class Bork {
//Property initializer syntax
instanceProperty = "bork";
boundFunction = () => {
return this.instanceProperty;
}
//Static class properties
static staticProperty = "babelIsCool";
static staticFunction = function() {
return Bork.staticProperty;
}
}
function foo(opts) {
opts = Object.assign({
pow: ''
}, opts);
}
Faster Font Loading with Font Events
Using combineReducers does "call all reducers", or at least all of the slice reducers it is wrapping.
Select visually the area to apply the changes then,
:retab
A service worker is run in a worker context: it therefore has no DOM access, and runs on a different thread to the main JavaScript that powers your app, so it is not blocking. It is designed to be fully async; as a consequence, APIs such as synchronous XHR and localStorage can't be used inside a service worker.
Statements:
- Declaration Statement
var a = 5
- Assignment Statement
b = a
- Expression statement
a
All statements have completion values event if its undefined
.