loverajoel / jstips

This is about useful JS tips!
http://jstips.co
GNU General Public License v3.0
12.5k stars 803 forks source link

Tilde Operator in JS #376

Closed bhaskarmelkani closed 8 years ago

bhaskarmelkani commented 8 years ago

Tilde(~) operator in JS.

TL;DR;

Tilde(~) is a unary operator that takes an expression( say N ) on its right and converts it to -(N+1).

Username

@bhaskarmelkani

Extra

kurtextrem commented 8 years ago

This tip is very similar to: https://github.com/loverajoel/jstips/blob/gh-pages/_posts/en/2016-01-15-even-simpler-way-of-using-indexof-as-a-contains-clause.md

loverajoel commented 8 years ago

closed by duplicated tip 😓