I have recently found the following code on the Ionic codePen:
$scope.add = function() {
var nextMessage = messageOptions[messageIter++ % messageOptions.length]; // some string
$scope.messages.push(angular.extend({}, nextMessage));
}
Why did the developer used angular.extend({}, nextMessage) as an input parameter of to javascript push function instead of directly passing the nextMessage as an argument?