Q
Q
Qubert2014-08-06 23:35:01
JavaScript
Qubert, 2014-08-06 23:35:01

How to insert an object in the push method?

Hey!

there is a code

$scope.gridObj.push({
  top: top_row_0				
});


i need to insert another object, how can i do that?

this principle does not work

$scope.gridObj.push({
  top: top_row_0,
        {
             left: 0,
             {
                top: 0
             }
        }
        
});



I need to insert an object exactly like this, thanks again will be added to these properties !

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Evgeny Petrov, 2014-08-06
@Qubert

Hey!
I have been a non-smoker for 2 years, and I would be glad if you share your weed I will be grateful if you tell me in more detail. Because it's not clear.
thank!

W
win_detto, 2014-08-07
@win_detto

Unclear.
Perhaps you want x to insert two objects into an array at the same time using the push method?
Then you can do this:

x = [];
x.push({y: 'x'}, {y: 'y'});
console.log(x); // --> [{y: 'x'}, {y: 'y'}]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question