Obj.lenght and calling methods

node v8.17.0
version: 1.0.0
endpointsharetweet
var obj = { "1234": "312", "4321": "198", "4231": "211", "3421": "323", "1423": "246" };
var getProp = function (propertyName) { return obj[propertyName]; };
console.log(getProp("1234"));
Object.getLength = function(obj) { var iLength = 0; for (var sKey in obj) { if (obj.hasOwnProperty(sKey)) iLength++; } return iLength; };
let objLeng = Object.getLength(obj);
console.log(obj[Object.keys(obj)[0]]);
for(i = 0; i < objLeng; i++) { console.log(obj[Object.keys(obj)[i]]); }
Loading…

no comments

    sign in to comment