Say: arr1 = ['a', 'b', 'c']
and arr2 = [0, 1, 2]
We want an object {'a' : 0}
This function throws a syntax error:
function makeObject(arr1, arr2) {
return {arr1[0] : arr2[0]}
}
but this is okay:
function makeObject(arr1, arr2) {
return {[arr1[0]] : arr2[0]}
}
Why and where can I find more documentation on this behavior?