标签:pre return tom 函数 creat string function 返回 str
var obj = {‘a‘:‘123‘,‘b‘:‘345‘}; console.log(Object.keys(obj)); //[‘a‘,‘b‘] var obj1 = { 100: "a", 2: "b", 7: "c"}; console.log(Object.keys(obj1)); // console: ["2", "7", "100"] var obj2 = Object.create({}, { getFoo : { value : function () { return this.foo } } }); obj2.foo = 1; console.log(Object.keys(obj2)); // console: ["foo"]
var str = ‘ab1234‘; console.log(Object.keys(obj)); //[0,1,2,3,4,5]
function Pasta(name, age, gender) { this.name = name; this.age = age; this.gender = gender; this.toString = function () { return (this.name + ", " + this.age + ", " + this.gender); } } console.log(Object.keys(Pasta)); //console: [] var spaghetti = new Pasta("Tom", 20, "male"); console.log(Object.keys(spaghetti)); //console: ["name", "age", "gender", "toString"]
var arr = ["a", "b", "c"]; console.log(Object.keys(arr)); // console: ["0", "1", "2"]
标签:pre return tom 函数 creat string function 返回 str
原文地址:https://www.cnblogs.com/yangsg/p/10270512.html