Reputation: 14632
I ran into a code in Javascript like this:
is_enabled = is_enabled | true;
What does it intend to do? To me it seems doing nothing.
Upvotes: 0
Views: 36
Reputation: 124
I think the code you are referring to is:
is_enabled = is_enabled || true
This allows the variable is_enabled
to be defined elsewhere in the code. So, is_enabled
's value is either it's previous definition, or if it has not been declared, it is true
.
Upvotes: 1