A simple metaphor I've heard used before is that a Promise in JavaScript is like ordering a cheeseburger at a fast food restaurant. When you pay for the cheeseburger, they give you a receipt with an order number on it. That receipt represents a placeholder...
There are only 4 different events that can trigger React component lifecycle methods:
When a Component Mounts
A component will only mount once during its lifecycle. The following 2 methods are only called once in the component's lifecycle alongside the component's render():
* componentWillMount()
* render()
* componentDidMount(...
Reliably testing for NaN has become much simpler (and safer) in ES6 using Number.isNaN( x ):
a = "foo" * 2;
b = "bar";
Number.isNaN( a ); // true
Number.isNaN( b ); // false
How is this different than the current isNaN( x )?
We are trying to test for, and...
Javascript’s number type is based on the “IEEE 754” standard, in which it specifically uses its double-precision, 64-bit binary floating-point format.
This means that some numbers really can’t be trusted to be exact. An infamous example is:
0.1 + 0.2 === 0.3;...
JavaScript strings do not have in place mutator methods like arrays do:
var arr = [ 'f', 'o', 'o' ];
arr.reverse();
arr; // Array [ 'o', 'o', 'f' ];
Since strings are immutable, we need a hack to accomplish the above with a string:
var str = 'bar';
str.split('')...