English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The every() method tests whether all elements in the array pass the test implemented by the provided function.
Note:This method returns true for any condition placed on an empty array.
array.every(callback, thisArg)
var nums = [1, 30, 39, 29, 10, 13]; var bool = nums.every(function(element) { return element >= 18; }); document.getElementById("result").innerHTML = bool;Test and See‹/›
The numbers in the table specify the first browser version that fully supports the every() method:
Method | |||||
every() | Is | 1.5 | Is | Is | 9 |
Parameter | Description |
---|---|
callback | The function to be executed for each element in the array. Function Parameters:
|
thisArg | Optional. An object to be used as the value of "this" when the callback is executed, passed to the function. If thisValue is omitted, the value of "this" is "undefined" |
Return Value: | If the callback function returns a true value for each array element, it is true; otherwise, it is |
---|---|
JavaScript Version: | ECMAScript 5 |