{} And function () {} use an empty object {} to store keyValue_javascript skills

Source: Internet
Author: User
Tags key case
Although everything in js can be an object, you can use the cramming method to add attributes to the object and assign values to attributes. however, some js built-in objects and type attributes cannot be overwritten are also greedy and mandatory. A js tool class that uses url operations has a property called queryString, my original practice was to make queryString = function (){},

The idea is to use either of the queryString [key] Or queryString (key [, value]) Write methods to call the key case-sensitive method using queryString [key ].

The queryString (key) method is case-insensitive.

Today, I found that none of the URLs contain the name parameter. Suddenly, queryString is an anonymous function, and the attributes such as name and length are read-only,

You can use another param (key [, value]) to implement the case-insensitive function.

The conclusion today is that it is better not to use function () {} to store keyValue for fields that have built-in attributes.
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.