Chi*_*nke 27 javascript boolean flip shorthand
如何在javascript中翻转布尔变量的值,而不必两次包含变量名?所以
foobarthings[foothing][barthing] = !foobarthings[foothing][barthing];
没有写foobarthings[foothing][barthing]两次.
foobarthings[foothing][barthing]
ale*_*lex 28
没有比你现在更短的方式了.
Sjo*_*erd 8
你可以这样做:
foo ^= 1
但这真的会在0和1之间切换foo,而不是真和假.
归档时间:
12 年,10 月 前
查看次数:
15902 次
最近记录:
7 年,3 月 前