Array with Expression
const list = [1+2, 1*2, 1/2];
console.log(list); // [ 3, 2, 0.5 ]
Triple Equal To (===)
let a = [1, 2, "3"]
a = a.filter((a, i) => a === Number(i))
console.log(a) # []
Iterating over Object
/* using for-in loop */
for (const prop in obj) {
if (obj.hasOwnProperty(prop)) {
console.log(prop, obj[prop]);
}
}
/* using Object.keys() - introduced in ES6 */
Object.keys(obj).forEach((prop, index)=>{
console.log(prop, obj[prop]);
});
/* using Object.values() - introduced in ES8 */
Object.values(obj).forEach((value)=>{
console.log(value);
});
/* using Object.entries() - introduced in ES8 */
Object.entries(obj).forEach((entry)=>{
console.log(entry[0], entry[1]);
});