The best modern Javascr ipt is simple, readable, and predictable. Learn to write modern Javascr ipt not by memorizing a list of new syntax, but with practical examples of how syntax changes can make code more expressive. Starting from variable decla
如果调用函数的过程中,定义的参数缺失,此参数变量的值则会是undefined。怎么给缺失的参数赋值默认值,在ES6之前,没有简洁的语法设置缺失参数的默认值,但是我们一般可以这么编写代码解决缺失参数默认值:
function myFunction(x, y, z) {
x = x === undefined ? 1 : x;
y = y === undefined ? 2 : y;
z = z === undefined ? 3 : z;
console.log(x, y, z); //