JavaScript · Junior · Question 53 of 75

What does arr.length = 0 do?

Explanation

Setting length truncates the array, and every reference to it sees the change. arr = [] instead points the variable at a new array.

Further reading

Problem with a question

JavaScript · Junior · question 53

Test yourself

Take the JavaScript · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz