0
Javascript: log([true, false].some(e => e));
Could you please help me interpret what happens here? let {log} = console; log([true, false].some(e => e));
4 Réponses
+ 3
Abhay Nope, some() is not mapping, instead some() and all() are for checking if the array fulfills certain condition, in this case, it checks whether some of the elements have a boolean value of true.
+ 2
The following line =>let{log}=console is destructuring of an object ,console is an object here and it has many properties like dir ,log and so on ,now you don't have to write console.log everytime ,you can just use log, sololearn has a lesson about it as well
Next in [true,false].some(e=>));
I will consider some as map function used here ,so whatever values are returned by this function ,map or other are logged out to the console
+ 2
Abhay Cool! Now I understand this snippet.
For easier reference for others, here is the SL lesson about object destructuring:
https://www.sololearn.com/learn/JavaScript/2977/
Gordon Also thanks for clarifying “some” (and all) array methods:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some
+ 1
Gordon ty for clearing that ,i never came across those methods