Correcting teacher:PHPz
Correction status:qualified
Teacher's comments:
function hello (name = "admin") {
return "Hello," + name;
}
console.log(hello())
admin
...REST
语法来解决
function hello (...names) {
return names;
}
console.log(hello("HTML","CSS","JS"));
...NAMES
的含义就是:将需要输出的内容,全部的压缩到了 NAMES
这个变量里面,而这个 NAMES
就变成了一个数组.
function jy (...names) {
return names;
}
let jieya = ["PHP","JAVA","PYTHON"]
console.log(jy(...jieya))
NAMES
这个数组中,然后在函数调用的时候再通过 ...JIEYA
这个解压操作将三个字符串解压出来....REST
语法用在函数参数中属于将字符串进行压缩的操作 | 当 ...REST
语法用在函数调用中属于将字符串进行解压的操作.${}