Built-in objects in js

Source: Internet
Author: User

Built-in objects in js
JavaScript charAt () function string. charAt (n) -- returns the character of the specified position (n)

  • CharIs the abbreviation of character, Chinese "symbol, character"
  • URL: http://www.dreamdu.com/javascript/string.charat/charat#syntax
    string.charAt(n);

    CharAt function parameters
    • N -- character position in the string (the first character of the string is 0) charAt function return value
      • Returns the n-Position Character.

        • If n is not between 0 and string. length-1, an empty string is returned.
        • JavaScript indexOf () function string. indexOf (substring, startpos) -- returns the position of substring in string.
          • Index, Chinese "Index"
          • URL: http://www.dreamdu.com/javascript/string.indexof/indexof#syntax
            string.indexOf(substring, startpos);
            IndexOf function parameters
            • Substring -- the substring to be searched
            • Startpos -- optional parameter. It is used to search for substring from the position of startpos of string. If this parameter is not available, the indexOf function return value will be searched from the start position of string.
              • Returns the position of the substring in the string.
              • The substring is not found in the string.-1 is returned.
              • JavaScript lastIndexOf () function string. lastIndexOf (substring, startpos) -- returns the position of the final match (appearance) of the substring in the string.
                • Last, Chinese "Last, last"
                • URL: http://www.dreamdu.com/javascript/string.lastindexof/lastindexof.pdf
                  string.lastIndexOf(substring, startpos);

                  LastIndexOf function parameters
                  • Substring -- the substring to be searched
                  • Startpos -- optional parameter. It is used to search for the substring from the startpos position of the string. If this parameter is not available, the return value of the lastIndexOf function is queried from the start position of the string.
                    • Returns the position where the substring matches the string.
                    • The substring is not found in the string.-1 is returned.
                      <script language="JavaScript" type="text/javascript">var myString="Welcome to Wrox books. ";myString=myString+"The Wrox website is www.Wrox.com. ";myString=myString+"visit the Wrox website today.";var foundAtPosition=0;var wroxCount=0;while(foundAtPosition !=-1){foundAtPosition=myString.indexOf("Wrox",foundAtPosition);if(foundAtPosition!=-1){wroxCount++;foundAtPosition++;}}document.write("there are+"wroxCount"+"occurrences of the word Wrox");</script>

                      JavaScript substring () function string. substring (startPos, endPos) -- returns the string from the string's startPos position to the endPos position
                      • Substring, Chinese "substring"
                      • URL: http://www.dreamdu.com/javascript/string.substring/substring#syntax
                        string.substring(startPos, endPos);

                        Substring function parameters
                        • StartPos -- start position
                        • EndPos -- Return Value of the end position substring Function

                          String

                          JavaScript substr () function string. substr (startPos, length) -- returns the string whose length is length from the position of startPos of string.
                          • It does not comply with ECMA standards and is not in favor of use.
                          • Substr, Chinese "substring"
                          • URL: http://www.dreamdu.com/javascript/string.substr/substr#syntax
                            string.substr(startPos, length);

                            Substr function parameters
                            • StartPos -- start position (when a negative number is obtained, it is calculated from the end of the string)
                            • Length -- Return Value of the substr Function

                              String

                              JavaScript toLowerCase () function string. toLowerCase () -- returns a lowercase string
                              • LowerCase, Chinese "lower case"
                              • URL: http://www.dreamdu.com/javascript/string.tolowercase/tolowercase#syntax
                                string.toLowerCase();

                                Return Value of toLowerCase Function

                                Returns a lowercase string.

                                JavaScript toUpperCase () function string. toUpperCase () -- returns an uppercase string.
                                • UpperCase, Chinese "uppercase"
                                • URL: http://www.dreamdu.com/javascript/string.touppercase/touppercase#syntax
                                  string.toUpperCase();

                                  Return Value of the toUpperCase Function

                                  Uppercase string

                                  ToUpperCase function example
                                  var str = "www.dreamdu.com";document.write(str.toUpperCase());

                                  Result:

                                  WWW.DREAMDU.COM


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.