+ 3
I don't understand an answer to a question amongst the Javascript challenges. Hoping someone can explain?
What is the output of this code? var x = 0; var arr = [4,9,2]; arr[x] = (++x) -1; document.write(arr[x]); Apparently the answer is 9. I don't understand why it's not 4.
2 Antworten
+ 5
The position 0 got replaced by 0
meanwhile, x was incremented so x is 1, because of the ++x
then it writes what is at the position 1 which is 9
I hope this helps :)
+ 2
Thank you.
For some reason I just couldn't make sense of the code :)
Looks like I need to refresh my memory on arrays.