Array - Return true if any element is true

If I have an array of boolean values, what is the cleanest/best way to check whether ANY values of the array are true?

[true, true, true] <-- want this to return true
[true, false, true] <-- want this to return true
[false, false, false] <-- want this to return false
[false, false, true] <-- want this to return true

I was reading about the "some" function of arrays and was thinking that might be what I want, but it requires a "callback function". It feels strange to have to write a function that only checks whether an input is true or false.
Code:
function checkTrue(val) {
    return val;
}
console.log([true, false, true].some(checkTrue));
// This works but feels awkward...
// I would rather not define a new function here
I am sure there is something obvious/simple that I'm missing.
Open to any ideas or help!
just return true, right?
Code:
myArray.some(function(isTrue) {return isTrue});
Naw, .some forEach. .filter and many more are awesome and should be used whenever possible.

PHP:
// with arrow function it's even cleaner.
console.log([true, false, true].some(value => value));

Everyone should learn es6 and basic functional programming. Your skills will improve double and code will become cleaner.
https://www.sitepoint.com/es6-arrow-functions-new-fat-concise-syntax-javascript/
@dbchest
Thanks man, I think you just introduced me to the wide world of anonymous functions. I had only ever done those to surround a plugin for variable scoping but now I'm seeing how useful it is.
Here's what works after some tinkering:
Code:
myArray.some(function(val){return val});

@LTN Games When I try the arrow function in the RPG Maker MV console, I get
"Uncaught SyntaxError: Unexpected token =>"
Does that mean RPG Maker MV doesn't support es6, or did I miss something in the install?
@Aloe Guvner man, my brain is screwy today. i forgot to add that. you got what i meant though, Lol.

@LTN Games yes. you had helped me in a previous post using the ES6 shorthand but i also received an unexpected token error. this whole es6 thing seems nice though.

edit
i updated it so one one will ever know. 😛
Oh sorry about that I thought arrow functions were available in 1.5.1 version. Well the beta 1.6 will work with the arrow functions so keep it in mind for the official release.

Funny thing .some() is an es6 function so some es6 works in 1.5.1 I just don't remember what because I always compiled with babeljs and been writing es6 for a year now.
@LTN Games what is babeljs?
@dbchest - http://babeljs.io

It's a compiler for turning modern JS into JS that'll run anywhere, like IE10 or the build of nw.js RMMV is using. (I prefer TypeScript; it's modern JS, but with types. Especially well-suited to HTML5 game dev.)

Also re: the topic, as LTN noted, this is the function you want (in ES6).

Code:
const callback = value => !!value;
const boolean = myArray.some(callback);

And in ES5...

Code:
var boolean = myArray.some(function (value) {
  return !!value;
});
EDIT 2: My original point was completely useless, but here's what you CAN gain from it:

Be careful that your array uses actual boolean values and not strings, or .some() is going to return TRUE no matter what (whether you return value or !!value).

For example, plugin parameters are always strings, even if the parameter type is listed as boolean during the parameter definitions, unless the plugin manually converts it to another type. (It's kind of a pain, and took me a while to figure out that I had a bug due to this very reason.)
Thank you @Llareian , that's a good point to keep in mind.
In this case, my data was an array of objects, where one of the object properties was an actual boolean.
The format was essentially like this (simplified):
Code:
myData = [ {name:"Foo", flag: true} , {name:"Bar", flag: false} , {name:"Foobar", flag: true} ];
I was safe to use the .some() function on the flag property of the objects in the array here but I'll definitely keep that in mind in the future.
What I would do personally is loop through each element of the array, and return true if it finds a true (effectively implementing shirt circuit evaluation). If it gets to the end of the loop with no matches, return false. This way you have full control of the behavior, and less likely to have bugs.

The function could look a bit like this. Replacing array with the name of the array to check. Apologies if my style isn't standard for JS, I learned C++ first and tend to write code in a manner similar to how I learned in C++.
Code:
for(var i = 0; i < array.length; i++)
{
     if(array[i] == true)
     {
         return true; // found a true value, exit the function
     }
}
return false; // only reached if there is no true value in the array

[true, true, true] <-- will return true on first loop
[true, false, true] <-- will return true on first loop
[false, false, false] <-- will return false after third loop
[false, false, true] <-- will return true on third loop
@Windows i7 - Array.some with a callback is definitely more idiomatic, especially if he's chaining array methods (see below). It's effectively the same as your solution, but it's more explicit. Your solution might have a slight edge in performance because of the perf hit from function calls, but that's a micro-optimization at best. (Array.some also short-circuits.)

Code:
const someTestValueisFive = myArray.map(e => e.test).filter(e => !!e).some(e => e === 5);
in the rmmv core , you have a method added to array prototype made by DEV

its not a reel js basic method but it a addon .
I dont know the performance , you may look console. performance now, and study the polyfill


PHP:
[false,false,false].contains(true); // return false
[false,true,false].contains(true); // return true
[true,true,true].contains(false); // return false
[true,0,true].contains(false); // return false
[true,"",true].contains(false); // return false
[true,"",true].contains(""); // return true
[1,0,3].contains(false); // return false
[1,0,3].contains(0); // return true
["",0,null].contains(false); // return false

// so
var itOk = myArrays.contains(true);
Thanks for the tip. If anyone was wondering, this is how that 'contains' is defined in rpg_core.js .

I couldn't see any noticeable performance difference on my (small) dataset with just simple testing in the console, though perhaps a more robust performance assessment could show something.

Code:
Object.defineProperties(Array.prototype, {
    contains : {
        enumerable: false,
        value: function(element) {
            return this.indexOf(element) >= 0;
        }
    }
}

Original thread: https://forums.rpgmakerweb.com/threads/array-return-true-if-any-element-is-true.88315/