what is use of tilde in js

//Combined with ~, it can do a boolean check if an item exists in a string value

var foo = "hello world";

if (~foo.indexOf("w")) {
  // item in list
} else {
  // item not in list
}

3.67
3
Sanat 85 points

                                    //Bitwise operator
console.log(~-2); // 1
console.log(~-1); // 0

//Converting Strings to Numbers
console.log(~~"-1");  // -1
console.log(~~"0");   // 0

3.67 (3 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
what is use of tilde in js javascript string tilde What mean tilde in javascript use variable in tilde javascript how to use tilde sign in javascript tilde operator in js js tilde string how to do tilde in javascript what does two tilde mean in javascript java script tilde javascript tilde string what is tilde mean in js variable with tilde in javascript tilde ~ in js tilde string javascript javascript using tilde symbol tilde meaning javascript what is tilde in javascript javascript tilde meaning javascript tilde symbol tilde operator ecma script tylde js "~" tilde operator javacsript tilde.js tilde symbol in js how to use tilde in javascript tilde oparator in javascript javascript tilda meaning of tilde in javascript require tilde javascript javascript use if condition in tilde what does the squiggly line mean in javascript javascript tilde in name variable what is the tilde operator in javascript squiggly operator js js tilde tilda in js what is tilde in js javascript bitwise indexof tilde symbol javascript javascript tilde operator js tilde operator before function js tilde operator tilde operator js tilde operator in typescript tilde operator javascript what does tilde do in typescript tilde in javascript tilde in js javascript tilde tilde operator in javascript tilde javascript js tilde function how to use Auth::user() in nodejs what is favicon.ico in html what is javascript written in what does tilde mean in javascript tilde js tilde $ means in js use of tilde in js
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source