So I'm copying a $scope.property
by defining it as the value of another variable var query
, and when I update the value of var query
it changes the value of $scope.property
.
Why does this happen and how can I avoid this?
My code looks something like this:
var query = $scope.property;
if(condition) {
console.log($scope.property);
$.extend(query, anotherObj);
console.log($scope.property);
}
The output in the console looks like this:
> Object {details-type: "order", details-bind_date_formatted: "03/19/2013"}
> Object {details-type: "order", details-bind_date_formatted: "03/19/2013", details-state: "CA"}
I've never encountered this problem in vanilla javascript.