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

What are the basic objects of JavaScript and how to use them

2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

Most people do not understand the knowledge points of this article "what are the basic objects of JavaScript and how to use them?" so the editor summarizes the following contents, detailed contents, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "JavaScript basic objects have what and how to use" article.

Basic object 1, function

The parameters passed in the function object will be placed in the arguements array. You only need to call the arguments array to get all the parameters.

/ / creation method 1function fun1 (aforme b) {alert (aforb);} / creation method 2var fun2=function (aforme b) {alert () aquib);} / / call method fun1 (3Power4); alert (fun1.length); / / display the number of formal parameters 2, Array object

The length of the Array object is variable, and so is the content type.

/ / creation method 1var arr=new Array (element list: 1Power2jue 3); / / creation method 2var arr=new Array (element length: 2); / / Note that the array length is represented by only one element in parentheses / / creation method 3var arr= [element list: 1meme 2rem 3j4]; 3. Date object var date = new Date (); [xss_clean] ((data.toLocalString ()) + "

") / / converted to local time format [xss_clean] ((data.getTime () +)"

") / / converted to milliseconds since 00:00 in 1970 4, Math object [xss_clean] ((Math.PI+"

") / π [xss_clean] ((Math.random () +)"

") / / Random number [xss_clean] ((Math.round (3.14) +"

") / / rounding [xss_clean] ((Math.floor (3.14) +"

") / / rounding up [xss_clean] ((Math.ceil (3.14) +"

") / / rounding down 5. RegExp (regular expression) object

Single character: []

[a] [abc] [amurf] / d: single numeric character / w: single word character [a-zA-Z0-9]

Quantifier symbol

? : appear 0 or 1 times *: appear 0 or more times +: appear at least once {mmagnetic n}: the number of occurrences is between m and n, which means at most or at least by default

End and start tag

^: opening tag $: closing tag / / creation method 1var reg=new RegExp ("regular expression:\\ w {6Magne12}") / / Note that\\ is needed to express\ / / creation method 2var reg=/ regular expression /

Determine whether the object can satisfy the regular expression by Text method

6. Global object encodeURI (str) / / url Encoding decodeURI (str) / / uri Decoding encodeURIComponent (str) / / url Encoding, more characters encoded decodeURIComponent (str) / / uri Decoding parseInt (str) / / determine whether each character is a number one by one, if it is not a number, stop judging, and convert the previous part to numberisNaN () / / only this can judge NaN, because the = = involved by NaN returns false Eval () / / execute the string code as script code. This is the content of this article on "what are the basic objects of JavaScript and how to use them?" I believe you all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.

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