Javascript

We'll shed some light on some mysterious Javascript constructs that are unfamiliar when you come from a different programming language. The 3 below are everything that should suprise you, that you will find used with Dashboard Hero or in adjacent libraries.

Equality comparators

Because objects are not strongly typed, there's an equality comparator that also does type checking: ===

Quick example:

var num = 0;
var obj = new String('0');

console.log(num == obj); // true
console.log(num === obj); // false

Further reading

Destructuring objects

Unpacks values from arrays.

Quick example:

[a, b] = [10, 20]; console.log(a); // expected output: 10

Further reading

Three dots operator

Array comprehension utility.

Quick example:

var parts = ['shoulders', 'knees']; 
var lyrics = ['head', ...parts, 'and', 'toes']; 
// ["head", "shoulders", "knees", "and", "toes"]

Further reading

Last updated

Was this helpful?