Imi Imi - 1 year ago 92
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

Answer Source

! 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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download