- 匿名函数
var test = function test1() { // 等于function() {} 匿名函数
console.log('aaa');
test1(); // 内部可执行
}
console.log(test.name) // test1
test1() // 外部报错
- 形实参
function test(a, b) {
console.log(test.length); // 2形参数量
console.log(arguments.length); // 3实参数量
}
test(1, 2, 3);
function test(a, b) {
a = 3;
console.log(arguments[0]); // 3可以改变实参的值
}
test(1, 2);
function test(a, b) {
b = 3;
console.log(arguments[1]); // undefined无法赋值
}
test(1);
function test(a = 1, b = 2) { // Es6出来的
console.log(a); // 1
console.log(b); // 3
}
test(undefined, 3);