To best understand the for..in and the for...of statements, we need to talk about enumerable properties and iterable objects from a high level.
Enumerable Properties and for...in Statements
Object properties are almost always seen as key/value pairs, but these properties also...
The scope model that JavaScript employs is called Lexical Scope. So what is it exactly?
A scope acts like a container in which your variables and functions are declared.
var name = 'Daniel';
function printName() {
console.log(name);
};
printName(); // Daniel
There are two scopes in this...
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...
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;...