【发布时间】:2019-11-16 13:02:15
【问题描述】:
在 Javascript 中使用可用于数组的内置方法时,某些方法将直接作用于调用数组。 例如,myArray.sort() 将按字母或数字升序对 myArray 进行排序。
myArray.sort();
// sort() acts directly on myArray, changing it in its place thereafter
// ... also myArray.reverse() amongst others.
而其他方法,例如 slice(),需要有一些东西,要么是变量,要么是其他输出,才能将其值返回给...
var need_a_new_array = myArray.slice(10, 21);
// a new placeholder is needed for the results of slice... if not using
// the results immediately (i.e. passing to another function or
// outputting the results)
我想知道这些方法及其差异的正确术语是什么。我在这里以数组为例,但我确信 一般的对象可能也是如此。 我很感激任何帮助。谢谢。
【问题讨论】:
标签: javascript arrays methods terminology