How can I access the object obj properties using a for loop?
Example:
var obj = {
id: 1,
description: "This space is for description",
severity: "This is severity",
assignedTo: "Name of the assigned person",
status: "Issue Status "
}
Note: I am talking about this kind of loop for (var i =0;i <= obj.length;i++), not a for ... in loop. I want to display it using document.write(). Please, no jquery, only javascript.
Object.keys()is there so it should help the OPfor..inis only JavaScript and you can still do dodocument.write()Do you have a specific issue withfor...in?Object.keys. it clearly states, the the result is an array with keys. then just loop through the array with for i ...Objects.keys()► stackoverflow.com/questions/8312459/… and.foreachcan easily be replaced byfor ion the result ofObject.keys()