数组、对象遍历收藏版
Code Is Never Die !
留存方便自己使用,方便大家使用
遍历对象:
1.Object.keys()
var obj = {'0':'a','1':'b','2':'c'}; |
2.for…in…
var obj = {'0':'a','1':'b','2':'c'}; |
3.Object.getOwnPropertyNames(obj)
var obj = {'0':'a','1':'b','2':'c'}; |
4.Reflect.ownKeys(obj)
var obj = {'0':'a','1':'b','2':'c'}; |
遍历数组:
1.forEach
var arr=[1,2,3,4]; |
2.for…in…
var arr=["张三","李四","王五","赵六"]; |
3.for…of….
var arr=["张三","李四","王五","赵六"]; |
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Rainux!
评论