function test() {
return arguments;
}
test(1, 2, 3)
[1, 2, 3]
function add() {
var res = 0;
for (var arg of arguments) {
res += arg;
}
return res;
}
add(1, 2, 3, 4, 5)
15
function tail() {
return arguments.slice(1);
}
tail(1, 2, 3)
TypeError: arguments.slice is not a function. (In 'arguments.slice(1)', 'arguments.slice' is undefined)
var tail2 = (...args) => args.slice(1);
tail2(1, 2, 3)
[2, 3]
var tail3 = (first, ...others) => others;
tail3(1, 2, 3)
[2, 3]
The console allows you to interact with the course material and examples. Use the following keys:
A special logging function is also available: