As logically concluded by the linq example: None is the same as !Any, so you could define your own utility method like this:
const none = (arr, callback) => !arr.some(callback)
And then call like this:
const arr = ["a","b","c"]
const hasNoCs = none(arr, el => el === "c") // false
const hasNoDs = none(arr, el => el === "d") // true
Demo in Stack Snippets
const none = (arr, callback) => !arr.some(callback)
const arr = ["a","b","c"]
const hasNoCs = none(arr, el => el === "c") // false
const hasNoDs = none(arr, el => el === "d") // true
console.log({hasNoCs, hasNoDs})
Answer from KyleMit on Stack OverflowAs logically concluded by the linq example: None is the same as !Any, so you could define your own utility method like this:
const none = (arr, callback) => !arr.some(callback)
And then call like this:
const arr = ["a","b","c"]
const hasNoCs = none(arr, el => el === "c") // false
const hasNoDs = none(arr, el => el === "d") // true
Demo in Stack Snippets
const none = (arr, callback) => !arr.some(callback)
const arr = ["a","b","c"]
const hasNoCs = none(arr, el => el === "c") // false
const hasNoDs = none(arr, el => el === "d") // true
console.log({hasNoCs, hasNoDs})
Not at the moment
At the moment I'm using an Array.some() and then negating the whole thing
Personally I think an Array.none function would be awesome
You could request it to be added to the next release of ECMA. It looks like a bit of a process to say the least but if we wanted to get this added to ECMA this would be the way.
Videos
Do:
opposite_index = arr.length - index - 1
For example:
a = [1,2,3,4,5,6,7,8,9,10]
index = 3
a[index]
4
It's opposite is 7 so:
opposite_index = a.length - index - 1
a[opposite_index]
7
With reverse as per @Maheer Ali suggestion:
a.reverse()[index]
7
Your Array(255).map() create undefined array value.So do with Array#from length object.And pass your value.get index of the value and match with reverse array you get opposite value
let check = (val) => {
var array_name = Array.from({length:255},(a,b)=>b+1);
var nor_ind = array_name.indexOf(val);
var re_in = array_name.reverse(array_name).indexOf(val)
return ({nor_val:val,nor_ind:nor_ind,opp_val:re_in})
}
console.log(check(254))