Array.includes does a strict comparison of array elements.
.container .row div
{
display: table;
margin: 0 auto;
}
#content
{
height: 100%;
display: table-cell;
vertical-align: middle;
}
But I want the result to return true in second case as well.My main goal is to know whether an array contains an element. Please suggest how this can be achieved.
答案 0 :(得分:3)
You can't use echo do_shortcode('[wpb_categories]');
, then. You can use some
:
includes
or in ES5:
console.log(array1.some(e => e == "2"));
console.log(array1.some(function(e) { return e == "2";}));
calls the callback you provide for the entries, in order, until your callback returns a truthy value, in which case some
stops and returns some
. If your callback never returns a truthy value (or the array is empty), true
returns some
.
false
was added in ES5 (2009).
Live example:
some