The javascriptevery () method is used to test whether all elements of the array have passed the test of the specified function. However, IE8 and the following browsers do not support the every method. This article introduces how to solve IE8 and the following methods that do not support the every function. For more information about the code farmers, see. In version 5th,
Every
Added to ECMA-262 standards; therefore not supported in some implementation environments. You can put the following code at the beginning of the script to solve this problem. This Code allows
Every
Is Used in the implementation environment. This algorithm is specified in ECMA-262 5th, assuming
Object
And
TypeError
Has their initial values, and
Fun. call
Equivalent
Function. prototype. call
.
If (! Array. prototype. every) {Array. prototype. every = function (fun/*, thisArg */) {'use strict '; if (this = void 0 | this = null) throw new TypeError (); var t = Object (this); var len = t. length >>> 0; if (typeof fun! = 'Function') throw new TypeError (); var thisArg = arguments. length> = 2? Arguments [1]: void 0; for (var I = 0; I <len; I ++) {if (I in t &&! Fun. call (thisArg, t [I], I, t) return false ;}return true ;};}