I have been looking into memory leak management for angularjs and I have came across $destroy
but in JavaScript there is already a delete
keyword. Is there a difference between the two?
Asked
Active
Viewed 195 times
-1

Nithin P.H
- 671
- 1
- 9
- 29
-
Possible duplicate of [AngularJS - Does $destroy remove event listeners?](https://stackoverflow.com/questions/26983696/angularjs-does-destroy-remove-event-listeners) – briosheje May 23 '18 at 05:30
1 Answers
1
In JavaScript delete operator removes a property from an object; if no more references to the same property are held, it is eventually released automatically.
var Employee = {
firstname: "Mohammed",
lastname: "Haddad"
}
console.log(Employee.firstname);
// expected output: "Mohammed"
delete Employee.firstname;
console.log(Employee.firstname);
// expected output: undefined
In angular , $scope.$destroy() is executed it will remove all listeners registered via $on on that $scope.
$scope.$on("$destroy", function() {
});

abdul subaan
- 91
- 6