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]
πŸ’¬ Discuss
βœ… Correct Answer: (A) [1]
Explanation: Setting length to 1 truncates the array to one element.
Explanation by: Chandani
Setting length to 1 truncates the array to one element.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
74
Total Visits
πŸ“½οΈ
1 y ago
Published
πŸŽ–οΈ
Chandani
Publisher
πŸ“ˆ
99%
Success Rate