Arguments?

Now pass the arguments. Tell me why the array is only 4, if on the idea of the loop should loop through all the arguments and record in a new array.
'use strict';

var array = [];

function sum() {
 for(var i = 0; i < arguments.length; i++) {
 return array[i] = arguments[i];
}
}

sum(4,5,2);

console.log(array)
March 23rd 20 at 19:03
1 answer
March 23rd 20 at 19:05
Solution
because returnwill terminate the loop for the first iteration

Find more questions by tags JavaScript