es6數組方法有:“from()”、“of()”、“copyWithin()”、“fill()”、“find()”、“findIndex()”、“includes()”、“entries()”、“keys()”、“values()”等。
本教程操作環境:windows7系統、ECMAScript 6版、Dell G3電腦。
傳統Array 對象方法
- toSource() 返回該對象的源代碼。
- toString() 把數組轉換為字符串,并返回結果。
- toLocaleString() 把數組轉換為本地數組,并返回結果。
- valueOf() 返回數組對象的原始值
修改原數組 | 不修改原數組 |
---|---|
push, pop | concat |
unshift,shift | join |
sort | slice |
reverse | indexOf(),lastIndexOf() |
splice | forEach |
copyWithin | map |
fill | filter |
some | |
every | |
reduce,reduceRight | |
includes | |
finde,findIndex | |
entries(),keys(),values() |
修改原數組
- push() 向數組的末尾添加一個或