Common built-in objects in JavaScript include Array objects, Math objects, Date objects and String objects. Built-in objects refer to the objects that come with JavaScript itself.
#The operating environment of this article: windows10 system, javascript 1.8.5, thinkpad t480 computer.
The built-in objects in JavaScript actually refer to the objects that come with JavaScript itself and provide some commonly used functions.
There are four common built-in objects, namely:
Array object: Provides an array model to store a large amount of ordered data.
Math object: can handle all mathematical operations.
Date object: can handle the storage, conversion and expression of date and time.
String object: can handle all string operations.
Mathematical object code example:
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> </head> <body> <script> console.log(Math); console.log(Math.PI);//输出为π console.log(Math.floor(1.9));//向下取整 console.log(Math.ceil(1.1));//向上取整 console.log(Math.round(4.3));//四舍五入 console.log(Math.abs(-33));//取绝对值 console.log(Math.max(1, 2, 3, 4, 5));//取最大值 console.log(Math.max.apply(null, [1, 2, 3, 4, 5]));//null表示this指针不替换 console.log(Math.min(1, 2, 3, 4, 5));//取最小值 console.log(Math.min.apply(null, [1, 2, 3, 4, 5])); console.log(Math.sqrt(100));//开平方 console.log(Math.pow(5, 3));//幂,5的3次方 console.log(Math.sin(90 * Math.PI / 180));//正弦,弧度=角度*π/180 console.log(Math.cos(180 * Math.PI / 180));//余弦 console.log(Math.tan(90 * Math.PI / 180));//正切 </script> </body> </html>
Related tutorial recommendations: js tutorial
The above is the detailed content of What are the common built-in objects in JavaScript. For more information, please follow other related articles on the PHP Chinese website!