【JavaScript】三种方法循环map取key和value.md

简书迁移

Posted by thrfox on June 29, 2020
1
2
3
4
//cssMap为一个Map
for(var key in cssMap) {
  content.css(key, cssMap[key]);
}
1
2
3
4
var key = Object.keys(cssMap);
for(var j = 0;j < key.length;j++) {
  content.css(key[j], cssMap[key[j]]);
}
1
2
3
4
$.each(cssMap,function (i,v) {
  content.css(i,v);
})