Y
A value greater than MAX-VALUE
|
prototype is a static property of a digital object. Use the properties of the prototype object to assign new properties and methods to the digital object in the current document.
3. Numerical method
##Method |
Description |
constructor() |
Returns the function that creates an instance of this object. By default this is a numeric object |
toExponentia
l()
|
Force a number to be displayed in exponential notation, even if the number is within the range that JavaScript normally specifies using standard notation |
toFixed() |
Format a number as a decimal with a specific number of digits to the right of the decimal point |
##toLocaleStrin ##g()
| The format of the string value version of the current number returned may change depending on the browser's regional settings
|
toPrecision( )
| defines the total number of how many to display a number (including the numbers to the left and right of the decimal point)
|
toString()
| Returns the string representation of the value of the number |
valueOf()
|
Return number The value of
| ## 2.
Boolean object
Boolean objects represent two values, either "true" or "false".
1. Create a Boolean object
##var val = new Boolean(value);
If the value parameter is omitted or the parameter is 0, -0, empty, false, NaN, undefined, or an empty string (" "), the initial value of this object is false.
2. Boolean attributes
##Attributes | Description |
constructor |
Returns a reference to the Boolean function that created this object |
##prototype |
## Prototype properties allow you to add an object's properties and methods
|
3, Boolean methods
Method
Description |
|
##toSource()
Returns a string containing the source of the Boolean object; you can use this string to create an equivalent object. |
|
toString()
According to the value of the object Returns "true" or "false". |
|
##valueOf()
Return the value of the number |
##3. | String object
The String object operates on a combination of characters (i.e., a string) through a large number of helper methods that hide the JavaScript string primitive data type.
Because JavaScript can automatically convert between original string arrays and string objects, you can call any auxiliary method of the string object to act on the original characters. String data.
1, Create a String object
##var val = new String(string);The parameter string is a correctly encoded character sequence.
2. String attribute
##Attribute | Description |
constructor |
Returns a reference to the Boolean function that created this object |
##prototype |
## Prototype properties allow you to add properties and methods of an object
|
##length
The length of the string |
3, String Object Method
##Method | Description |
charAt() |
Returns the character at the specified position |
charCodeAt() |
Returns the Unicode encoding of the character at the specified position |
concat() |
##Connection string
|
indexOf()
|
Retrieve string
|
lastIndexOf()
|
Retrieve string from back to front
|
localeCompare()
| ##Compares two strings in locale-specific order
|
match()
| Find one or more regular expressions Match
|
replace()
| Replacement and regular Substring matched by the expression
|
search()
| Retrieve values that match the regular expression
|
##slice()
Extract fragments of the string and return the extracted parts in the new string |
|
split()
Split the string into a string array |
|
substr()
Extract the specified number of characters from the string from the starting index number |
|
substring()
#Extract the characters between the two specified index numbers in the string |
|
toLocaleLowerCase()
Convert the string to lowercase |
|
toLocaleUpperCase()
|
Convert the string to uppercase |
##toLowerCase() |
Convert the string to lowercase |
##toString()
|
Return string
|
##toUpperCase() | Convert the string to uppercase
|
##valueOf()
| Return the value of the number
4, HTML basic type wrapper for String
Method |
Description |
author() |
Create an HTML anchor as a hypertext target |
big() |
Creates a string displayed in large font , just like the effect of using the tag |
##blink() | Create a string flashing display, just like the effect of using the |
#bold( )
|
Create a string bold display, just like the effect of using tag
|
fixed()
|
Creates a string displayed as typewriter text, just like using the tag Effect
|
fontcolor()
|
Create a string Use the specified color to display, just like the effect of using the tag
|
#fontsize()
| Create a string to be displayed using the specified size, just like using the tag
|
italics()
| Creates a string that is italicized, just like using < ;i> Effect of label
|
##link()
Create an HTML hyperlink to request another URL |
| ##small()
Create a string to display in a small font size, just like using the tag |
# #strike() |
Creates a string that is displayed with a strikethrough, just like using the tag |
sub() |
Creates a string displayed as a subscript, just like using < sub> Effect of label |
##sup() |
Create a string displayed as a superscript, just like using the tag |
4. Array object
Array object is used to store multiple values in a single variable.
1. Create an Array object
# #var fruits = new Array("apple","orange","mango"); |
Parameters of the array Can be a set of strings or integers. When you specify a numeric argument to the array constructor, the initial length of the array is determined. The maximum length allowed for an array is 4,294,967,295.
An array can be created by simple assignment, as shown below:
var fruits = ["apple","orange","mango"]; |
##You can access and set the value of the elements in the array through the serial number (subscript), as follows:
• fruits [0] is the first element
• fruits[1] is the second element
• fruits[2] is the third element2,
array attribute
Properties
Description |
|
constructor
|
Returns a reference to the function that created the object
|
index
|
Retrieve the matching string starting from zero
|
input
|
Only found in arrays created via regular expressions
|
length
|
Set or return the number of elements in the array
|
##prototype
|
Prototype properties allow you to add properties and methods of an object
|
3, Array object method
##Method | Description |
concat() |
Concatenates two or more arrays and returns the result |
every() |
Apply the specified function to the array elements to judge. When And only if all return values are true, return true, otherwise return false se |
filter() |
Create a new array. The elements in the array are the elements in the original array that satisfy the filter function return value and are empty |
forEach() |
Traverse the array from beginning to end and call the specified function for each element |
indexOf() |
Retrieve from beginning to end and return the index of the given element in the array Index |
join() |
Put all the elements in the array element into a string. Elements are separated by the specified delimiter |
lastIndexO
f()
|
Retrieve from the end to the beginning and return the index of the given element in the array |
##map()
|
Create a new array to store the return value of calling the specified function for each element in the original array
|
pop()
|
Delete and return the last element of the array
|
##push()
| Adds an or to the end of the array more elements and returns the new length.
|
##reduce()
At the same time, Apply a function to two values to reduce to a single value (from start to finish) |
|
reduceRigh
t()
Apply a function to two values in the array at the same time, reducing it to a single value (from tail to head) |
| ##reverse()
Reverse the order of the elements in the array |
shift() |
Delete and return the first element of the array |
##slice() |
From an existing array Returns the selected element |
##some()
|
Apply the specified function to the array elements to judge. Only one return value is true, return true, otherwise return false
|
##toSource( )
| Return the source code of the object
|
##sort ()
Sort the elements in the array |
| # #splice()
Insert or delete elements in the array |
| toString()
Convert the array to a string and return the result |
| unshift()
Adds one or more elements to the front of the array and returns the length of the new array |
5. Date object |
The Date object is a built-in data type of the JavaScript language . Date objects are created using new Date() as shown below.
Once a Date object is created, many methods can be used to manipulate it. Most methods only allow getting and setting the year, month, day, hour, minute, second, and millisecond fields of the object, either in local time or Coordinated Universal Time (UTC, GMT).
The ECMAScript standard requires that a Date object be able to represent any date and time, accurate to the millisecond, within 100 million days before or after 1/1/1970. This is a range of plus or minus 273785 years, so JavaScript can represent dates and times up to the year 275755.
1. Date() constructor
##new Date()
new Date(milliseconds)
new Date(datestring)
##new Date(year,month,date[,hour,minute,second,millisecond])
Parameter description:
No Argument: Without parameters, the Date() constructor creates a date object and sets it to the current date and time.
milliseconds: When a number is passed as a parameter, it is used as an internal number representing milliseconds in the date, and as the milliseconds in the return value of the getTime() method. For example, passing the parameter 5000 creates a date object that represents 5 seconds past midnight on 1/1/1970.
datestring: When passing a string as a parameter, it must be a string in date form, that is, a format that can be received by the Date.parse() method.
7 agrument: For the last form of the constructor given above, here is a description of each parameter:
year: Integer, representing year. For compatibility (to avoid Y2K issues) the year should be specified in its entirety; use 1998 instead of 98.
month: Integer, representing month. Starting from 0 (meaning January) to 11 (meaning December).
date: Integer, representing a certain day of the month.
hour: Integer, representing a certain hour of the day (24-hour format).
minute: Integer representing the minute fragment of the time count.
#second: Integer representing the seconds fragment of the time count.
#milliseconds: Integer, representing the millisecond fragment of the time count.
2. Date attribute
Attribute |
Description |
constructor |
Returns a reference to the function that created the object |
prototype |
##Prototype properties allow you to add properties and methods of an object |
3, Date method
##Method | Description |
Date() |
Returns the date and time of the day |
getDate() |
Returns a certain day of the month (1 ~ 31) from the Date object based on local time |
##getDay()
|
According to local time from Date The object returns a day of the week (1 ~ 6)
|
##getFullYear()
| Return the year as a four-digit number from the Date object based on local time
|
getHours()
| Returns the hour of the Date object according to local time (0 ~ 23)
|
getMilliseconds()
| Returns the milliseconds of the Date object (0 ~ 999) according to the local time
|
getMinutes()
| Returns the minutes of the Date object (0 ~ 59) according to local time
|
getMonth()
| Returns the month (1 ~ 11) from the Date object according to local time )
|
##getSeconds()
Returns based on local Seconds of Date object (0 ~ 59) |
| ##getTime()
Returns the number of milliseconds from January 1, 1970 to the present based on local time |
##getTimezoneOffset() |
Returns the minute difference between local time and Greenwich Mean Time (GMT) |
getUTCDate() |
Returns the day of the month (1 ~ 31) from the Date object according to universal time |
getUTCDay() |
Returns the day of the week (0 ~ 6) from the Date object based on universal time ) |
##getUTCFullYear() |
##According to the universal time from Date object returns four-digit year
|
getUTCHours() |
Returns the hour of the Date object (0 ~ 23) |
##getUTCMillisecond
s()
|
Return the milliseconds of the Date object (0 ~ 999) according to universal time |
getUTCMinutes() |
Returns the minute of the Date object according to universal time (0 ~ 59) |
getUTCMonth() |
Returns the month (0 ~ 11) from the Date object according to universal time |
getUTCSeconds() |
Returns the seconds of the Date object (0 ~ 59) according to world time |
##getYear()
|
Deprecated, returns the specified Dates are based on local time. Use getFullYear() instead.
|
##setDate()
| Set Date according to local time A certain day of the month in the object (1 ~ 31)
|
##setFullYear()
Set the year in the Date object (four digits) according to local time |
|
setHours()
Set the hour in the Date object according to local time (0 ~ 23) |
| setMilliseconds()
Set the milliseconds in the Date object (0 ~ 999) according to local time |
|
setMinutes()
Set the minutes in the Date object (0 ~ 59) according to local time |
|
setMonth()
Set the month in the Date object according to local time (0 ~ 11) |
|
setSeconds()
Set the seconds in the Date object according to local time (0 ~ 59) |
|
setTime()
Set the Date object in milliseconds according to local time |
|
setUTCDate()
|
Set the day of the month in the Date object (1 ~ 31) according to universal time |
setUTCFulYear() |
Set the year (four digits) in the Date object according to universal time |
setUTCHours() |
Set the hour (0 ~ 23) in the Date object according to the universal time |
setUTCMillisecond
s()
|
Set the milliseconds in the Date object (0 ~ 999) according to the world time |
setUTCMinutes() |
Set the minute in the Date object (0 ~ 59) according to universal time |
setUTCMonth() |
Set the month in the Date object (0 ~ 11) according to universal time |
setUTCSeconds() |
Set the seconds in the Date object (0 ~ 59) according to world time |
setYear() |
Deprecated, set to the specified date according to the local time. Use setFullYear() instead. |
toDateString() |
Put the date of the Date object Partially converted to a string |
toGMTString() |
Deprecated, converts the date to a string, using the Internet GMT convention. Use toUTCString() instead. |
##toLocalDateString() |
##According to the local time format, Convert the date part of the Date object to a string
|
toLocalFormat()
|
Convert the date to a string, using the format string.
|
##toLocalString()
| According to the local time format, Convert Date object to string
|
toLocalTimeString()
| Convert the time part of the Date object into a string according to the local time format
|
##toSource()
|
Returns a string representing the source code of an equivalent date object. You can use this value to create a new object |
toString() |
Convert Date object to string |
toTimeString() |
Convert the time part of the Date object into a string |
toUCTString() |
Convert the Date object to a string according to world time |
valueOf() |
Returns the original value of the Date object |
##Date static method
Method | Description |
##Date.parse()
|
Return the number of milliseconds from midnight on January 1, 1970 to the specified date (string)
|
Date.UTC( ) |
##Returns the number of milliseconds from January 1, 1970 to the specified date according to universal time
|
6. Arithmetic objectThe Math object provides functions for mathematical constants properties, methods and functions. #Unlike other global objects, Math is not a constructor. All properties and methods of Math are static, and you can call all its properties and methods by using Math as an object without creating it. # Therefore, you can define the constant pi as Math.PI, or you can call the sin function Math.sin(x), where x is the parameter of the method. 1. Simple use
##var pi_val = Math.PI; var sine_val = Math.sin(30);
2, Math attribute
##Attribute | Description |
E |
Returns the arithmetic constant e, which is the base of the natural logarithm (approximately equal to 2.718) |
LN2 |
Returns the natural logarithm of 2 (approximately equal to 0.693) |
##LN10
|
Returns the natural logarithm of 10 (approx. Equal to 2.302)
|
LOG2E
|
returns 2 as Logarithm of the base (approximately equal to 1.414)
|
##LOG10E
| Return the logarithm of base 10 (approximately equal to 0.434)
|
##PI
Return pi (approximately equal to 3.14159) |
| ##SQRT1_2
Returns the reciprocal of the square root of 2 (approximately equal to 0.707) |
| ##SQRT2
Returns the square root of 2 (approximately equal to 1.414) |
3, Math method
##Method | Description |
abs() |
## Returns the absolute value of the number
|
acos()
|
Returns the arc cosine of the number
|
asin()
|
Returns the arcsine of the number
|
atan()
| ## is between -PI/2 and PI/2 A value in radians to return the arctangent of x
|
##atan2()
Returns the angle from the x-axis to the point (x,y) (between -PI/2 and PI/2 radians) |
|
ceil()
Round up the number |
|
cos()
Returns the cosine of the number |
|
exp()
Returns the exponent of e |
|
floor()
Round down the logarithm |
|
log()
Returns the natural logarithm of the number (base is e) |
|
max()
Return the highest value between x and y |
|
min()
##Return the lowest value between x and y |
| pow()
Returns x raised to the y power |
##random() |
Returns between 0~1 Random number |
round() |
Round the number is the nearest integer |
sin() |
Returns the sine of the number |
sqort() |
Returns the square root of the number |
tan() |
Returns the tangent of the angle |
toSource() |
##Returns the source of the object Code |
Related recommendations:
JS basics document object in DOM Detailed explanation of commonly used attribute methods
JS method to dynamically add attributes to objects
|
|
|
|
|
|
|
|