JS: Using indexOf() without -1

1
2
var text = 'text';
~text.indexOf('asd'); //text contains asd - false
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Bitwise operators perform their operations on such binary representations, but they return standard JavaScript numerical values.

From: https://github.com/loverajoel/jstips

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.