Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Detailed introduction of global functions in javascript

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly explains "the detailed introduction of global functions in javascript". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Now let the editor to take you to learn "the detailed introduction of global functions in javascript"!

The operating environment of this tutorial: windows7 system, javascript1.8.5 version, Dell G3 computer.

JavaScript global function

The function describes decodeURI () to decode an encoded URI. DecodeURIComponent () decodes an encoded URI component. EncodeURI () encodes the string as URI. EncodeURIComponent () encodes the string as a URI component. Escape () encodes the string. Eval () evaluates the JavaScript string and executes it as script code. IsFinite () checks whether a value is a finite number. IsNaN () checks whether a value is a number. Number () converts the value of the object to a number. ParseFloat () parses a string and returns a floating point number. ParseInt () parses a string and returns an integer. String () converts the value of the object to a string. Unescape () decodes the string encoded by escape ().

DecodeURI () function

The decodeURI () function decodes the URI encoded by the encodeURI () function.

Syntax: decodeURI (uri)

Uri: required. A string containing the URI or other text to be decoded.

DecodeURIComponent () function

The decodeURIComponent () function decodes the URI encoded by the encodeURIComponent () function.

Syntax: decodeURIComponent (uri)

EncodeURI () function

The encodeURI () function encodes the string as URI.

The encodeURI () function does not escape the following ASCII punctuation marks that have a special meaning in URI: /?: @ & = + $# (you can use the encodeURIComponent () method to encode ASCII punctuation marks with special meaning respectively.) .

Syntax: encodeURI (uri)

EncodeURIComponent () function

The encodeURIComponent () function encodes the string as a URI component.

This method does not encode ASCII letters and numbers, nor does it encode these ASCII punctuation marks:-_. ! ~ * ().

Other characters (such as: /?: @ & = + $, #, the punctuation marks used to separate URI components) are replaced by one or more hexadecimal escape sequences.

Syntax: encodeURIComponent (uri)

Escape () function

The escape () function encodes a string so that it can be read on all computers.

This method does not encode ASCII letters and numbers, nor does it encode the following ASCII punctuation marks: * @-_ +. / . All other characters are replaced by escape sequences.

Syntax: escape (string)

String: required. The string to be escaped or encoded.

Eval () function

The eval () function evaluates the JavaScript string and executes it as script code.

If the parameter is an expression, the eval () function executes the expression. If the argument is a Javascript statement, eval () executes the Javascript statement.

Syntax: eval (string)

IsFinite () function

The isFinite () function is used to check whether its argument is infinite, or it can be understood as a finite number (finite number).

Syntax: isFinite (value)

Value: required. The number to be detected.

Return value: if the parameter is NaN, positive infinity or negative infinity, false will be returned, and other parameters will return true.

IsNaN () function

The isNaN () function is used to check whether its parameters are non-numeric.

Syntax: isNaN (value)

Returns true if the parameter value is NaN or non-numeric values such as string, object, undefined, etc., otherwise it returns false.

Number () function

The Number () function converts the value of an object to a number.

Syntax: Number (object)

If the value of the object cannot be converted to a number, the Number () function returns NaN.

ParseFloat () function

The parseFloat () function parses a string and returns a floating point number.

This function specifies whether the first character in the string is a number. If so, the string is parsed until the end of the number is reached, and then the number is returned as a number, not as a string.

Syntax: parseFloat (string)

ParseInt () function

The parseInt () function parses a string and returns an integer.

Syntax: parseInt (string, radix)

When the value of the parameter radix is 0, or when it is not set, parseInt () determines the cardinality of the number based on string.

When the parameter radix is omitted, the cardinality of the default number for JavaScript is as follows:

If string starts with "0x", parseInt () parses the rest of the string into hexadecimal integers.

If string starts with 0, ECMAScript v3 allows an implementation of parseInt () to parse subsequent characters into octal or hexadecimal numbers.

If string starts with a number from 1 to 9, parseInt () parses it to a decimal integer.

String () function

The String () function converts the value of an object to a string.

Syntax: String (object)

Unescape () function

The unescape () function decodes a string encoded by escape ().

Syntax: unescape (string)

Note: unescape () cannot be used for selective decoding of URI (Universal Resource Identifier: UniformResourceIdentifier, referred to as "URI"). Use the decodeURI () method to decode the URI.

At this point, I believe you have a deeper understanding of the "detailed introduction of global functions in javascript". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report