A

Admin • 828.03K Points
Coach

Q. What will be logged?

Code:
let arr = [1, 2, 3];
arr.length = 1;
console.log(arr);
  • (A) [1]
  • (B) [1, 2, 3]
  • (C) []
  • (D) [1, 2]
  • Correct Answer - Option(A)
  • Views: 8
  • Filed under category JavaScript
  • Hashtags:

Explanation by: Admin
Setting length to 1 truncates the array to one element.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.