Javascript frequently used

Find string in a string

indexOf () method returns the index of the specified text string in the first occurrence (position):

lastIndexOf () method returns the index of the specified text string of the last occurrence of:

If the text is not found,  indexOf () and  lastIndexOf () both return -1

 

 

search () method returns the text string of the first occurrence of the specified location:

String length

property returns the length of the string length:

toString () method

toString () Returns a string value

toExponential () method

toExponential () Returns a string value that has been rounded comprising using the number of exponential notation.

toFixed () method

toFixed () Returns a string value that contains the specified number of decimal digits:

toPrecision () method

toPrecision () Returns a string value that contains the number specified length:

These three methods can be used to convert JavaScript variable numbers:

  • Number () method
  • parseInt () method
  • parseFloat () method

These methods are not digitally, but global JavaScript method

Get Time

getDate() In return values ​​days (1-31)
getDay() Numerical week to get the name (0-6)
getFullYear() Get four-digit years (yyyy)
getHours() Obtaining hour (0-23)
getMilliseconds() Get milliseconds (0-999)
getMinutes() Gets points (0-59)
getMonth() Gets month (0-11)
getSeconds() Gets seconds (0-59)
getTime() Acquisition time (from 1 January 1970 to date)

Guess you like

Origin www.cnblogs.com/li496903/p/11918738.html