Object.values()
(does not have wide browser support yet)
Object.keys()
check the key presence in an object:
const a = { key: 1 }
'not-present' in a // false
'key' in a // true
best conditional assignment:
;(function (smth) {
if ( 'key' in smth ) return;
smth.key = {
// do your stuff
}
})('smth' in window && window.smth || (window.smth = {}))
parseInt('011',2)
(4).toString(2)
"a".charCodeAt(0) // 97
String.fromCharCode(97); // 'a'
log = function() {
const context = "My Descriptive Logger Prefix:";
return Function.prototype.bind.call(console.log, console, context);
}() // <- !!!
do not use them semicolons mandatory:
;(d + e).print() // line starts with parenthesis or square bracket
quote from the article:
If you choose to omit semicolons where possible, my advice is to insert them immediately before the opening parenthesis or square bracket in any statement that begins with one of those tokens, or any which begins with one of the arithmetic operator tokens
/
,+
, or-
if you should happen to write such a statement.