I’m trying to understand the documentation for the Array function toObject.
It uses [‘zero’, ‘one’, ‘two’].toObject((x, index) => index, x => x.contains(‘two’)) as an example, which returns {“0”: false, “1”: false, “2”: true}.
What does the (x, index) portion of the expression mean? If I reverse the order to {index, x}, use {index}, or use index then the output always returns {zero:false, one:false, two:true}. What is (x, index) and why is it special here?
Thank you for your answer. I think I can narrow my question. ‘x’ and ‘index’ are not features of my object. They’re keywords for the expression interpretation. Are there other keywords? Why does the index expression need two parameters (x, index) and for them to be in that order?