JavaScript 在参数中传递新数组
JavaScript pass new array in argument
有没有一种方法(就像我们在 C# generics/linq list.take... 中那样)可以在调用函数时在参数中获取数组元素的范围,而不必创建一个新数组?
//a simple array with some elements
myArray;
//just to show what I mean...pass the first five elemtns of array to the function
doSomethingWithArray(myArray[0,4]);
function doSomethingWithArray(items) {
//do stuff
}
有没有一种方法(就像我们在 C# generics/linq list.take... 中那样)可以在调用函数时在参数中获取数组元素的范围,而不必创建一个新数组?
//a simple array with some elements
myArray;
//just to show what I mean...pass the first five elemtns of array to the function
doSomethingWithArray(myArray[0,4]);
function doSomethingWithArray(items) {
//do stuff
}