6 ES6 Tips for More Efficient JavaScript Coding
Array.of: Consistent Array Creation
The Array constructor in JavaScript can behave unexpectedly based on the number of arguments passed:
// Inconsistent behavior of Array constructor
const arr1 = Array(3); // [ , , ]
const arr2 = Array(); // []
const arr3 = Array(undefined); // [undefined]
const arr4 = Array(1, 2, 3); // [1, 2, 3]
This inconsi ...
Posted on Thu, 30 Jul 2026 16:53:40 +0000 by scottfossum
Modern JavaScript Features in ES7 and ES8
ES7 Features
Array.prototype.includes()
The includes() method determines whether an array contains a specified element, returning true or false.
Basic Syntax:
const elements = ['x', 'y', 'z'];
console.log(elements.includes('x')); // true
console.log(elements.includes('w')); // false
Specifying Start Index:
const letters = ['a', 'b', 'c', 'd']; ...
Posted on Mon, 18 May 2026 11:30:22 +0000 by lookee