Javascript: log([true, false].some(e => e)); | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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));

24th Aug 2020, 1:49 PM
Prof. Dr. Zoltán Vass
4 Answers
+ 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.
24th Aug 2020, 5:34 PM
Gordon
Gordon - avatar
+ 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
24th Aug 2020, 2:09 PM
Abhay
Abhay - avatar
+ 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
24th Aug 2020, 7:15 PM
Prof. Dr. Zoltán Vass
+ 1
Gordon ty for clearing that ,i never came across those methods
24th Aug 2020, 7:31 PM
Abhay
Abhay - avatar