获取对象的键值名

var demoArr = ['Javascript', 'Gulp', 'CSS3', 'Grunt', 'jQuery', 'angular'];
var demoObj = {
aaa: 'Javascript',
bbb: 'Gulp',
ccc: 'CSS3',
ddd: 'Grunt',
eee: 'jQuery'
};

1.Object.keys(demoObj) //['aaa','bbb','ccc','ddd','eee'];

2.$.each(demoArr, function(e, ele) {
  console.log(e, ele);
})
//输出
0 "Javascript"
1 "Gulp"
2 "CSS3"
3 "Grunt"
4 "jQuery"

posted on 2017-07-12 17:35  转身回头处  阅读(3782)  评论(0编辑  收藏  举报

导航