JavaScript attack (v) JS Object

Source: Internet
Author: User

In JavaScript, all things are objects. JavaScript allows custom objects to be customized.

Objects are special data types with properties and methods.

To access the properties of an object:

Common Properties

Methods for accessing objects:

Common methods

(What is the meaning of creating JavaScript objects, and why do you do this, there is no substitute)

There are two ways to create JavaScript objects

1. Define and create an instance of the object;

2. Use the function to define the object, and then create a new object instance.

JavaScript numbers

Regardless of the decimal point, all JavaScript numbers are 64 bits, the root is 10 64 bits (8 bits), and the floating point number.

Accuracy: integer (not applicable to decimal or exponential notation) up to 15 bits, the maximum number of decimal digits is 17, but floating-point arithmetic is not always 100% accurate:

Well, that's the difference between 64 bits and 15, 17 bits.

Octal and hexadecimal

If the prefix is 0, JavaScript interprets numeric constants as octal numbers, and if the prefixes are 0 and "X", they are interpreted as hexadecimal numbers.

Tip: Do not write 0 in front of the number unless you need to make an octal conversion.

The properties and methods of the numbers:

Properties:
    • MAX VALUE
    • MIN VALUE
    • Negative infinitive
    • POSITIVE Infinitive
    • NaN
    • Prototype
    • Constructor
Method:
    • Toexponential ()
    • ToFixed ()
    • Toprecision ()
    • ToString ()
    • ValueOf ()

A String object is used to handle an existing block of characters.

Common:

Calculates the length of the string, using the Length property to calculate the length of the string.

Adds a style to a string, adding a style to the string.

The IndexOf () method uses indexOf () to position the first occurrence of a specified character in a string.

The match () method uses match () to find a specific character in the string and, if found, returns the character.

How to replace a character in a string-replace (), using the Replace () method to replace some characters with some character in a string.

Date objects are used to process dates and times.

Common:

Returns the date and time of the current day, using the date () method to get the day.

GetTime (), returns the number of milliseconds since January 1, 1970.

setFullYear (), use setFullYear () to set the specific date.

toUTCString (), use toUTCString () to convert the date of the day (based on UTC) to a string.

GetDay (), using GetDay () and arrays to display the week, not just the numbers.

Displays a clock that displays a clock on the page.

The purpose of an array object is to use a separate variable name to store a series of values.

Common:

Create An array, assign a value to it, and then output the values.

For ... the in declaration uses the For...in declaration to loop through the elements in the output array.

merges two arrays-concat () How to use the Concat () method to merge two arrays.

the elements of an array-join () How to use the Join () method to compose all the elements of an array into a string.

text array-sort () How to use the sort () method to literally sort the array.

Numeric Array-sort () How to use the sort () method to sort the arrays numerically.

Boolean (logical) objects are used to convert non-logical values to logical values (TRUE or false).

Common:

Check that the logical value checks whether the logical object is TRUE or false.

The Math object works by performing common arithmetic tasks.

Common:

Round () How to use round ().

The random () uses random () to return a number from 0 to 1.

How Max () uses Max () to return a larger number of two given numbers. (Before ECMASCript v3, the method has only two parameters.) )

Min () How to use min () to return a smaller number of two given numbers. (Before ECMASCript v3, the method has only two parameters.) )

The RegExp object is used to specify what is retrieved in the text.

What is REGEXP?

REGEXP is the abbreviation for regular expressions.

When retrieving a text, you can use a pattern to describe what you want to retrieve. REGEXP is this pattern.

The simple pattern can be a single character.

More complex patterns include more characters and can be used for parsing, format checking, substitution, and so on.

You can specify the location of the search in a string, the type of character to retrieve, and so on.

The RegExp object is used to store the retrieval mode.

Define the RegExp object with the New keyword. The following code defines the RegExp object named Patt1, whose pattern is "e":

var patt1=New RegExp ("E");

When you use the RegExp object to retrieve in a string, the character "e" is searched.

The RegExp object has 3 methods: Test (), exec (), and compile ().

The test () method retrieves the specified value in the string. The return value is true or false.

The EXEC () method retrieves the specified value in the string. The return value is the value that was found. If no match is found, NULL is returned.

You can add a second parameter to the RegExp object to set the retrieval. For example, if you need to find all the existence of all a character, you can use the "G" parameter ("global").

The compile () method is used to change the REGEXP.

Compile () can either change the retrieval mode or add or remove the second parameter.

JavaScript attack (v) JS Object

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.