Igor Simic

How to push data in javascript object

How to add new items to javascript object, or how to push data in JS object:

var defaultTags = [];
      //loop the object $scope.editContent.tags
      angular.forEach($scope.editContent.tags, function(value, key) {
                // create new object with some data for every loop
                var newObject = {};
                  newObject["id"] = 1;
                  newObject.id = value.hashid;

                  newObject["name"] = 1;
                  newObject.name = value.tags;
      }, defaultTags);
      $scope.selectedTags = defaultTags