Javascript中常见的内置对象有哪些
4952
javascript中常见的内置对象有Array对象、Math对象、Date对象和String对象。内置对象就是指javascript本身自带的对象。
javascript中的内置对象其实就是指javascript本身自带的对象,并且提供了一些常用的功能而已。
常见的内置对象有四种,分别是:
Array对象:提供一个数组的模型来存储大量有序的数据。
Math对象:可以处理所有的数学运算 。
Date对象:可以处理日期和时间的存储、转化和表达。
String对象:可以处理所有的字符串的操作。
数学对象代码示例:
- <!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>
本文网址:https://www.zztuku.com/detail-8998.html
站长图库 - Javascript中常见的内置对象有哪些
申明:如有侵犯,请 联系我们 删除。
您还没有登录,请 登录 后发表评论!
提示:请勿发布广告垃圾评论,否则封号处理!!