πŸ“Š JavaScript
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

πŸ‘οΈ
57
Total Visits
πŸ“½οΈ
9 mo ago
Published
πŸŽ–οΈ
Chandani
Publisher
πŸ“ˆ
81%
Success Rate