javascript every nested array 1

javascript every nested array

var array = [[false, false, false, false], [false, false, false, false], [false, false, false, false], [false, false, false, false]],
    result = !array.some(a => a.some(Boolean));

console.log(result);

Here is what the above code is Doing:
1. It creates a 2D array with all false values.
2. It uses the Array.prototype.some() method to check if any of the values in the array are true.
3. It uses the Array.prototype.some() method again to check if any of the values in the array are true.
4. It uses the ! operator to negate the result of the Array.prototype.some() method.
5. It logs the result to the console.

Similar Posts