What does!~ mean in JS?

Source: Internet
Author: User

 (function   () { var  names = [];  return  function   (name) {addname (name);  function   AddName (name) { 
   
    if  (!~names.indexof (name)) 
    // 
     If present, do not add         
     Names.push (name); Console.log (names);  
    // 
     ["Linkfly"]  
     ' linkfly '); 
   

Original code
The highest bit of the original code notation is the sign bit, which is 0 for positive numbers and 1 for negative numbers. The remaining bits represent the absolute value of the number.
Anti-code
For a signed number, the inverse code of positive numbers is the same as its original code, and the inverse of negative numbers is reversed for each of its original code except the sign bit. The inverse code is often used to do the intermediate form in the process of seeking the complement.
Complement
The complement of a positive number is the same as the original code and the inverse code, and the complement of the negative is the opposite of the symbol bit of the original code, and is obtained by adding 1 at the bottom, that is, the complement of the numbers plus 1. The number in the computer is usually in the form of a complement. In the complement ( -128) d instead of ( -0) d, note: ( -128) d does not correspond to the original code and the inverse code, ( -128) d = (1000,0000) B.
Calculation of the complement
The complement operation does not consider the symbol bit, the original code of the people take the reverse, and in the bottom plus 1 to get. The complement of a number is the inverse number of the number.

If the operator in the!~names.indexof (name) "!~" what meaning, do not understand, start from ~.

The test can draw the result value has this Law-(x+1)

IndexOf for 0 is to take the anti-nonexistent!0 to true Add. Indexof==-1//to do's xx notation

What does!~ mean in JS?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.