I was reviewing the code for an angularjs factory to better understand how it works. The code contains an if
statement that I don\'t fully understand.
I
!! converts a value to a boolean (true or false). +
then converts that boolean to a number, either 1
for true
or 0
for false.
> +true
1
> +false
0
Personally I find it clearer to write something like this, when dealing with two booleans:
if (!config.template == !config.templateUrl) {
throw ...
}
Code clarity and readability be damned, apparently.