JS Basic article

Source: Internet
Author: User

This article only records the usual easy to ignore knowledge points

1, variable declaration

Variables must start with a letter

Variables can also start with the $ and _ symbols (although we do not recommend this)

Variable names are case sensitive (Y and y are different variables)

2,indexof Search Differences

Indexof,search can see whether the specified string is in a string, and returns the location of the first occurrence of the specified string in the string.

If you just look for a specific string, the system resources using indexof () are less expensive and more efficient; If you are looking for a string with some characteristics (such as looking for a string that starts with a, followed by a number), then indexof () is powerless. You must use the regular expression and the search () method.

Many times using indexof () is not to really want to know the location of the substring, but rather to know that the long string does not contain this substring. If the return index value is-1, then the description does not: Not equal to 1, then there is.
So in general, indexof is more resource-saving than search.

JS Basic 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.