Shorthand for flipping a boolean variable

Chiel ten Brinke picture Chiel ten Brinke · Dec 20, 2012 · Viewed 17.5k times · Source

How can I flip the value of a boolean variable in javascript, without having to include the variable name twice? So

foobarthings[foothing][barthing] = !foobarthings[foothing][barthing];

without writing foobarthings[foothing][barthing] twice.

Answer

alex picture alex · Dec 20, 2012

There is no shorter way than what you currently have.