function getKeysOfObject() { let o = {'a': 1, 'b': function() {}, 'c': 2}; console.log(Object.keys(o)); } getKeysOfObject(); Result:["a", "b", "c"] ----------------------------------------------- function addPropertyToObj() { let o = {}; o['a'] = 87; console.log(o); } addPropertyToObj(); Result: {a: 87} -------------------------------------------------- function processStringWithMap() { let str = 'hello'; let map = Array.prototype.map; let a = map.call(str, function(e) { return e.concat('N')}); console.log(a); } processStringWithMap(); Result: ["hN", "eN", "lN", "lN", "oN"]
来源:https://www.cnblogs.com/tsai-87/p/12162225.html