1. 程式人生 > >js中鑒別數組暨與偽數組的區別

js中鑒別數組暨與偽數組的區別

js

arr instanceof Array;//true為數組

偽數組
其實是Object對象
具有length屬性
具有數值下標屬性
沒有數組特別的方法
:forEach(),push()

varweiArr={}
weiArr.length=0;
weiArr[0]=‘atguigu‘;
weiArr.length=1;
console.log(weiArr instanceof Array);//false


本文出自 “Rcid” 博客,請務必保留此出處http://13419255.blog.51cto.com/13409255/1975774

js中鑒別數組暨與偽數組的區別