Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to push an object to an array

var object = {name: 'Bhavansh'};
var array = [ ]; // Create empty array

// Add object to the array
	array.push(object); 
    
// To access the object
	console.log(array[0].name);
 
PREVIOUS NEXT
Tagged: #push #object #array
ADD COMMENT
Topic
Name
4+3 =