JavaScript Coding Question – 15

  • [ a, , b] = array : Here, a is assigned the first element of array, which is 10. Second element is skipped by using comma(,). b is assigned with the third element of the array, which is 30.
  • array.fill(5, 1, 2) : fill method modifies the original array. Here it replaces elements from index 1 to 2(index 2 is excluded) with the value 5.
  • result = b + array[1] : Here b is 30 and value of array[1] is 5. So 30+5 is 35.

Leave a comment