Get the App
SLTechnology News&Howtos  ›  Development  › 

How JavaScript uses the ~ operator

Shulou Source: shulou.com Published: 2022-06-01 04:37:40 10月03日 Update

I would like to share with you how JavaScript uses the ~ operator. I believe most people don't know much about it, so share this article for your reference. I hope you will learn a lot after reading this article. Let's learn about it together.

~ operator

~ symbol used in JavaScript has the function of inversion by bit, that is, it is inverted twice, and the operation value of bit operation is required to be an integer, and the result is also an integer, so after bit operation, it will automatically become an integer, which can skillfully remove the decimal part, similar to parseInt, such as:

Let a = 1.23 * let b =-1.23 * * console.log (~ a); / / 1console.log (~ b); /-1 is all the content of the article "how JavaScript uses the ~ ~ operator". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Operations operators integers articles content ingenious not so useful most decimal more knowledge symbols results industry information information channels parts channels seeking truth Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Docker NVidia Xiaomi Shulou Technology