JavaScript duels question. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

JavaScript duels question.

Hello everybody, i've faced an interesting question during one of JS duels. It had loop for...of. for (let {x=2, y=3} of [{x=1},{y=4}]) { arr.push(x,y);} And somehow it pushed 1,2,3,4 to the array(arr). From what i know for...of syntax is 'for (variable of object) {};' And this loop assigns value of each element in object(or anything iterable) to a variable. I've tried to Google it, but didn't find any answers. Could anyone explain this behaviour to me? Thanks a lot in advance.

1st Nov 2018, 12:28 PM
BlackDrake
2 Answers
+ 2
eeh the syntax in that code is throwing errors and is wrong,please retrace the question and provide the correct version
1st Nov 2018, 1:27 PM
᠌᠌Brains[Abidemi]
᠌᠌Brains[Abidemi] - avatar
1st Nov 2018, 1:36 PM
BlackDrake