JS: Using indexOf() without -1

var text = 'text'; ~text.indexOf('asd'); //text contains asd - false ~text.indexOf('ext'); //text contains ext - true
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.