1

I try to Insert new data in an object as an object. But the problem is when i use array.push() method it inserts new data/data's in a array first then push it into my desire object but as an array.

here is the code

var new_data = this.filter_posts.slice(0,3); this.current_posts.push(new_data);

and for understand purpose i post ta console log console log

coder618
  • 848
  • 1
  • 9
  • 12

1 Answers1

0

Try using spread operator this.current_posts.push(...new_data);

var x = []
var y = []

var items = [1,2,3]

// what you are doing:
x.push(items)

console.log(x)

// what you need
y.push(...items)

console.log(y)