How to set or update or push the values into Object in javacript

27-02-2017 javascript set update push object

Object Basics

Here the values push to the object

var arr = []; // Declare the array
arr.push('value');

Here the value set into the object

arr[1].name = 'test';
console.log(arr[1].name);

Here the initilize the object

var var ={'id':1,'name':'test'};
console.log(var);

Display the all names from the object

var arr = [{name: 'test1'},{name: 'test2'}];
for(var i=0;i<arr.length;i++){
     console.log(arr[i].name+'<br>');
}

 

You might also like:

Convert Time 24 hrs to 12 hrs format In javascript
12-03-2017 date javascript 12hrs convert
Get next date from given date in javascript
06-03-2017 date javascript next date
How to find Angular Errors
06-03-2017 errors angularjs exceptionHandler
Filter for change Date Time format (MM-dd-yyyy HH:mm) in Angular Js
05-03-2017 mm-dd-yyyy HH:MM date formats angular js
Call a function every second or 5 seconds in javascript
22-02-2017 setinterval function calling