Some properties and methods of built-in objects in JavaScript

Source: Internet
Author: User

JavaScript Object Summary
JS has built-in 17 objects, commonly used is an array object, a Date object, a regular Expression object, a String object, a global object
Common methods in array objects:
Concat (): Represents the merging of several arrays into an array.
Join (): Returns a string value that contains all the elements of an array joined together, separated by the specified delimiter.
Pop (): Removes the last element of the divisor group.
Shift (): Removes the first element in an array.

Unshift (): The first item in the array
Slice (Start,end): Returns a paragraph in the array.
Push (): Adds a new element to the array, returning the latest length.
Sort (): Sorts the array.
Reverse (): Reverses the ordering of the array.
toLocaleString (); Returns the current system time
Array object properties are commonly used for only one:
Length: Indicates the current array size is obtained

Global Object
is an intrinsic object that concentrates all global methods in one object.
Global has no syntax and calls its methods directly.
Escape (): Encodes a String object so that they can be read on all computers.
Escape (charstring)
Required option The Charstring parameter is any String object or literal that you want to encode.
IsNaN (): Determines whether a value is Nan.
parseint (): Returns the integer that is obtained by the string

Regular Expression Object
This object contains the regular expression pattern and flags that indicate how the pattern is applied.
Syntax 1
Re =/pattern/[flags]

Syntax 2
Re = new RegExp ("pattern", ["flags"])
Re is the name of the variable that will be assigned the regular expression pattern
Pattern is a regular expression
Flags as marked: There are 3 of the following
1:g (full-text search)
2:I (ignoring case)
3:M (multi-line lookup)
Syntax 1 is used when finding a string in advance. Use Syntax 2 when finding a string that is constantly changing or not known, such as a string that is obtained by user input.
String Object
CharAt (): Character that returns the position of the specified index
Concat (): Returns a String value representing the connection of two or more strings
Match (): uses the regular expression pattern to perform a lookup on a string and returns the most results that contain the lookup results
function Matchdemo () {
var r, re; Declares a variable.
var s = "The rain in Spain falls mainly in the plain";
re =/ain/i; Creates a regular expression pattern.
r = S.match (re); Try to match the search string.
return (R); Return to the place where "Ain" first appeared.
}

Replace (b): Character B replaces a
Search (Stringobject): Indicates whether there is a corresponding match. If a match is found, the search method returns an integer value indicating the offset from the beginning of the match distance string. If no match is found, 1 is returned.
Slice (start,end): Return segment Fragment
Split (): String split
Substr (start,length): String intercept
Substring (Start,end) Gets the string within the specified length
toUpperCase (): Returns a string in which all letters in the string are converted to uppercase letters.
toLowerCase (): Returns a string that all letters in the string are converted to lowercase letters.

Some properties and methods of built-in objects in JavaScript

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.