We can use the destructing and rest parameters at the same time when dealing with Array opration. Example 1: let [first, ...remainingUsers] = ["Sam", "Tyler", "Brook"]; addActiveUsers(first, remainingUsers); // "Sam"…
In es5, you can use indexOf to get the index of one item in an array. In es6, you can use findIndex(), which is more prowful: [NaN].indexOf(NaN) // -1 [NaN].findIndex(y => Object.is(NaN, y)) You can use with splice() function: _cartItems.splice( _car…
Here is the way you get value from an object: var obj = { color: "blue" } console.log(obj.color); //blue Destructuring Assignment: Object Destructuring Assignment is somehow different: var {color} = { color: "green" } console.log(color…
if (!Array.prototype.find) { Array.prototype.find = function(predicate) { 'use strict'; if (this == null) { throw new TypeError('Array.prototype.find called on null or undefined'); } if (typeof predicate !== 'function') { thro…