💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
## 1、 [4, 5, 6] ; ["张三", 2, 3] funciton fn(arr){ arr[0] = '张三' //修改全局对象arr arr = [4,5,6] //修改argument对象 console.log(arr) //argument对象 } var arr = [1,2,3] fn(arr) console.log(arr) //全局对象 ## 2、 5;5 function fn(){ var a = b = 5 console.log(a) console.log(b) } fn() ## 3、 0;5 function fn(){ console.log(a) console.log(b) var a = b = 5 //提升到顶部 => b=5;var a=b => b是全局对象,a是内部对象 } fn() ## 4、 5 function fn(a){ function fn(a){ console.log(a) => var a; var a = 10 console.log(a) } a = 10 fn(5) } ## 5、ƒ a( ){console.log(a)} ;1 var a = 1; function fn(a){ console.log(a) var a = 2 function a( ){ console.log(a) } console.log(this.a) // this=>全局对象 a( ) } fn(3) ## 6、使用递归方法计算 1+2+3+4+5=15 [[https://juejin.im/entry/594a48395c497d006b0dfcf6](https://juejin.im/entry/594a48395c497d006b0dfcf6)] function sum(n){ if(n==1) return 1; return sum(n-1) + n; }