Imi Imi - 8 months ago 65
AngularJS Question

what does =! means in javascript

I came across this line while reading source code of an application.

$scope.editMode = ! $scope.editMode;

I wonder what does this is not the not the not equal to operator. I tried it in this jsfiddle the answer is correct but I still do not understand the logic is this somehow an equal to operator?


$ = 'Superhero';
$scope.hero = '123'
$ = ! $scope.hero


! is used to reverse boolean value. For example:

!(true) = false and 
!(false) = true

In your example

$scope.editMode has assigned to reversion of $scope.editMode