Anon
0
Q:

javascript array push object

array.push(element)
27
var colors= ["red","blue"];
	colors.push("yellow"); 
41
array = ["hello"]
array.push("world");
6
var fruits = [ "Orange", "Apple", "Mango"];

fruits.push("Banana"); 
4
let items = [1, 2, 3]
items.push(4); // items = [1, 2, 3, 4]
6
//push in object javascript
var data = [];
// ...
data[0] = { "ID": "1", "Status": "Valid" };
data[1] = { "ID": "2", "Status": "Invalid" };
// ...
var tempData = [];
for ( var index=0; index<data.length; index++ ) {
    if ( data[index].Status == "Valid" ) {
        tempData.push( data );
    }
}
data = tempData;
2
var object = "Some Object"
var array = []

array.push(object)
1
var myArray = [];
myArray.push("Example");
myArray.push("text");
2
var a=[]
var b={};
a.push(b);    
2
function getKeyValue(object) {
    return Object.keys(object).reduce(function (result, key) {
        return result.concat(
            object[key] && typeof object[key] === 'object' ?
            getKeyValue(object[key]) :
            [[key, object[key]]]
        );
    }, []);
}

var data = { id: 23, name: "Jacob", link: { rel: "self", link: "www.abc.com", }, company: { data: { id: 1, ref: 324 } } };

console.log(getKeyValue(data));
0

New to Communities?

Join the community