how to loop over string value and fetch other key value pair inside it in javascript code example
Example 1: javascript loop through object
let obj = { first: "John", last: "Doe" };
Object.keys(obj).forEach(function(key) {
console.log(key, obj[key]);
});
for (const key of Object.keys(obj)) {
console.log(key, obj[key]);
}
Object.entries(obj).forEach(
([key, value]) => console.log(key, value)
);
Example 2: going through every attributes of an object javascript
let a = {x: 200, y: 1}
let attributes = Object.keys(a)
console.log(attributes)