Answers for "js create jaon object from for loop"

0

loop through object js

var obj = {
  first: "John",
  last: "Doe"
};

//
//	Visit non-inherited enumerable keys
//
Object.keys(obj).forEach(function(key) {

  console.log(key, obj[key]);

});
Posted by: Guest on February-02-2020
-1

js create jaon object from for loop

var loop = [];

for(var x = 0; x < 10; x++){
 loop.push({value1: "value_a_" + x , value2: "value_b_" + x});
}

JSON.stringify({array: loop});
Posted by: Guest on February-18-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language