Amazing Little Things

One thing I love about programming is that, even after 15 years, I still come across little things that amaze me.

This JavaScript (derived from an answer on stack overflow) toggles the value used by an HTML checkbox.

isChecked ^= 1;

This trivial logic combined with JavaScript’s peculiar type conversion mechanics results in one of the most elegant expressions of intent I’ve ever seen in a single line of code.

Leave a Reply

Your email address will not be published. Required fields are marked *