老韩哥

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

{
// 默认值后面不能再有没有默认值的变量

function text(x,y = 'world') {
console.log('默认值',x,y)
}
text('hello')
text('hello','覆盖')

}

{
let x='test'
function test(x,y=x){
console.log('作用域',x,y)

}
test('kill')// kill kill
}

{
function test2(...arg){
for(let v of arg){
console.log('rest',v)
}

}
test2(1,2,3,'s')// 转换成数组
}

{

console.log(...[1,2,3])// 转换成值,与上面相反
console.log('a',...[1,2,3])
}


{
// 箭头函数 函数名,参数,返回值
let arrow = v => v*2
console.log(arrow(3))

let arrow2 = () => 2//参数为空的时候要写成()
console.log(arrow2())
}

{
// 伪调用 提升性能 我是想不到有啥用。。。。
function test1(x) {
console.log('tail',x)
}
function test2(x) {
return test1(x)
}

test2(123)
}

posted on 2020-05-01 10:36  老韩哥  阅读(77)  评论(0)    收藏  举报