js的函数传参的方式是按值传递,正常情况下,改变函数参数的值,并不会对函数外部的变量造成影响。例如: 'use strict'; var list = [1, 2, 3]; list.forEach(function(item) { item ++; }); console.log(list); // [ 1, 2, 3 ] 这是因为js的函数在接收参数时,会生成一个副本变量,该副本变量等于参数的值,可以分析js这样运行的: 'use strict'; var list = [1, 2, 3]; list.forEach(function(item, i) { // 第一个item是副
评论星级较低,若资源使用遇到问题可联系上传者,3个工作日内问题未解决可申请退款~