Javascript:the Evil Parts-1

Source: Internet
Author: User

I recently looked at the JavaScript framework design and mentioned some "unthinkable situations" when explaining the type decision, but it was not stated exactly when the situation would occur. Play for yourself and write essays. But there may be other times when I find out about these weird phenomena. 2333

Question: When will it appear in JavaScript?
    1. a !== a
    2. a == b && b != a
    3. a == !a
    4. a == b && a == c && b != c
    5. a != b && a != c && b == c
Answer
  1. Refer to ECMA-262 Edition 5.1 section 11.9.6, actually! = is also true (refer to 11.9.3)

    var a =//  true
  2. Only ie6~8 will appear (because window does not belong to the ECMAScript constraint range)

    var a = window;var b == = = B && b! = a);  // true
  3. Refer to ECMA-262 Edition 5.1 section 11.9.3, which is also explained here

    var a == = =!a);  // true
  4. Javascript:the from Douglas Crockford good Parts, also refer to 11.9.3, here are explained
     var  A = 0;  var  b = ";  var  C = ' 0 ' ;console.log (a  = = b && A  = = C && b! = c); //  
  5. The source is the same as the 4th way
    var false ; var b = undefined; var NULL  ! = B && A! = c && b = = c);  // true

The Black magic in JavaScript is horrible, aha, haha ... Although it is a little bit of a thing, but the actual development may really be in the case of the pit. So, in most cases, still can use = = = = = = Good ...

Javascript:the Evil Parts-1

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.