前端建立、遍歷map集合前端
var dataMap = { props: {}, Set: function (key, value) { this.props[key] = value }, Get: function (key) { return this.props[key] }, Contains: function (key) { return this.props[key] == null ? false : true }, Remove: function (key) { delete this.props[key] } }
前端建立map集合,而且附帶了set、get、contains、remove方法this
方法使用:code
dataMap.Set(「id」, "test_id");
前端遍歷map集合:rem
for
(
var
prop
in
map){
get
if
(map.hasOwnProperty(prop)){
io
console.log(
'key is '
+ prop +
' and value is'
+ map[prop]);
console
}
function
}
test