Obj.lenght and calling methods
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]]);
}
no comments