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

How to understand JavaScript deeply

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article shows you how to deeply understand JavaScript. The content is concise and easy to understand. It will definitely brighten your eyes. I hope you can gain something through the detailed introduction of this article.

Regular expression

a. Create a regular expression

1. Literal: / xyz/i, compiled at load time

two。 Constructor: new RegExp ('xyz','i'), compiled at run time

3. Identification:

G (global), a given rule can be matched multiple times

I (ignoreCase), ignoring case when trying to match a given regular

M (multiline), in multiline mode, the start operator ^ and the end operator $match each line

b. Regular method

RegExp.prototype.test (): whether there is a match

String.prototype.search (): index of matching positions

RegExp.prototype.exec (): capture packets

String.prototype.match (): captures packets or returns all matching substrings

String.prototype.replace (): find and replace

c. Some problems with identification / g

1. Regular expressions with / g cannot be inlined

two。 Regular expression with / g as parameter: for security reasons, lastIndex should be set to 0 (when test () and exec ())

3. Share regular expressions with / g: lastIndex needs to be set to 0

d. Tips and skills

1. Regular expressions that lack assertions (such as ^, $) can match anywhere

two。 Match everything: new RegExp ('') .test () or / (?:) /, not any character: / .^ /

e. Regular expression cheat sheet: P310

Https://github.com/zhangyue0503/html5js/blob/master/speakingjavascript/19.js

Date

A.Date constructor

1.new Date (year, month,date?,hours?,minutes?,seconds?,milliseconds?)

B.Date prototype method

Date.prototype.get (): returns unit time based on local time

Date.prototype.set (): sets the unit time based on local time

Date.prototype.getUTC (): returns unit time based on world time

Date.prototype.setUTC (): sets unit time based on world time

Date.prototype.getTime (): returns the number of milliseconds (since 1970.1.1)

Date.prototype.setTime (): specifies the date in milliseconds

Date.prototype.valueOf (): call this method when the date is converted to a numeric value

Date.prototype.getTimezoneOffset (): returns the deviation between local time and world time in minutes

Date.prototype.getFullYear (): get the year

Date.prototype.setFullYear (): set year

Date.prototype.toTimeString (): returns the time of the current time zone

Date.prototype.toLocaleTimeString (): the returned time format is region-specific

Date.prototype.toDateString (): returns the date

Date.prototype.toLocaleDateString (): date with regional characteristics

Date.prototype.toString (): the returned date and time fall within the current time zone without milliseconds

Date.prototype.toLocaleString (): with regional characteristics

Date.prototype.toUTCString (): return to world time

Date.prototype.toISOString (): all internal attributes appear in the returned string

Date.prototype.toJSON (): convert date to JSON string

Math

A.Math attribute

Math.E (Euler constant), Math.LN2 (natural logarithm of 2), Math.LN10 (natural logarithm of 10), Math.LOG2E (logarithm of e with base 2), Math.LOG10E (logarithm of e with base 10), Math.PI (pi), Math.SQRT1_2 (square root of 1amp 2), Math.SQRT2 (square root of 2)

b. Numerical function

Math.abs (): absolute value

Math.ceil (x): returns the smallest integer greater than or equal to x

Math.exp (x): returns the x power of e

Math.floor (x): returns the largest integer less than or equal to x

Math.log (x): returns the natural logarithm of x

Math.pow (x): returns the y power of x

Math.round (x): returns the integer closest to x

Math.sqrt (x): returns the root sign x

c. Triangulation function

Math.acos (x): returns the inverse cosine of x

Math.atan (x): returns the arc tangent of x

Math.cos (x): returns the cosine of x

Math.sin (x): returns the sine of x

Math.tan (x): returns the tangent of x

d. Other functions

Math.min (…) Returns the smallest number in the parameter, which can be applied to the array through apply

Math.max (…) Returns the largest number in the parameter, which can be applied to the array through apply

Math.random (): returns a pseudorandom number, 0

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

Internet Technology

Wechat

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

12
Report