Question #35

Author: admin
tags: JavaScript  
function getArray(num) {
  if (num === 4) {
    return [4, 4, 4, 4]
  }
  else {
    return 1
  }
}

let x = 2

x = getArray(4)

[2].toFixed(0), x = x

console.log(x) // ??
What will the console output be?
It will output nothing, there will be a TypeError error.
0
1
[1]
4
'4' (string)
[4]
[4, 4, 4, 4]
2
'2' (string)
This is a question for fans not to write semicolons.
The string [2].toFixed(0), x = x takes the third element from the array.
It should also be noted that the comma operator has the lowest priority, so assignment is performed first.
Rate the difficulty of the question:
easyhard