The third equal signs of JavaScript "=" and the essence of new string ("")

Source: Internet
Author: User

VaR STR = "ABC" and STR = new string ("ABC"); Are there any differences? In fact, there is a difference,New String ("ABC") creates an object whose value is "ABC". What does the object Value mean by "ABC? It is something inside JavaScript. In short: Str = "ABC", the STR variable points to a constant string object, and STR = new string ("ABC,
STR points to an object type variable. The two objects are different.


The rule for the third equal sign "=" is as follows. If one variable points to the constant type and the other points to the object type, it must be different, for example, the assignment methods of the above two "ABC" methods do not want to be equal. if it is an object variable, it depends on whether it points to the same object. If it is a constant variable at the same time, it depends on whether the value is the same. of course, the values of constant objects of different types must be different.

Related Article

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.