let fn= function(a,b){
return a + b ; }
console.log(fn(1,2));
let fn= function(a,b=3){
return a + b ; }
console.log(fn(1));
let fn =function(a,b){
return a+b;
}
console.log(fn(1,2,3,4,5));
//无法接受到全部的参数,这里我们需要用剩余参数’…‘
let fn =function(a,b,...c){
console.log(a,b,c)
}
fn(1,2,3,4,5);
//把数组打散
let arr= [1,2,3,4,5];
console.log(...arr);
console.log(fn(...arr));
`
let ss = function(){
return [1,3,3,4,5,6,4,6,]}
console.log(ss());
function sss(){
return{
id:1,
name:'jack',
email:'php@cc'
}
}
console.log(sss());
let name = `PHP中文网`;
console.log(`hello ${name}`);
let xxx=1;
console.log(`${xxx? `这是${name}` :`输入错误` }`);
第一个参数:模板字面量中的””字符串字面量”(strings)
第二个参数:模板字面量中的””插值”数组(…args)` calc`订单:${10}单价:${5}`
function calc(strings,...args){
console.log(strings);
console.log(args);
console.log(args[0] * args[1]);
}