In this form - [{x: y} {x: y} {x: y}]; ?

Closed due to the fact that the essence of the question is not clear by the participants user207618, Kromster , Bald , Darth , Vadim Ovchinnikov Jul 1 '17 at 14:18 .

Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • and more specific question? need a function? - Aliaksandr Pitkevich
  • the cycle is necessary ...... - YURII

2 answers 2

So, like you, only with commas.

var y = null; var arr = [{ x: y }, { x: y }, { x: y }]; console.log(arr); // или var arr1 = []; for (var i = 0; i < 3; i++) arr1.push({ x: y }); console.log(arr1); 

    through cycle

     let y = 'y'; let arr = []; for (let i = 0; i < 3; i++) { arr.push({x:y}); } console.log(arr);