1、内置对象介绍
内置对象就是指 JS 语言自带的一些对象,这些对象供开发者使用,并提供了一些常用的或是最基本而必要的功能(属性和方法)
内置对象最大的优点就是帮助我们快速开发
1.1 Math 对象
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script>
console.log(Math.abs(1));
console.log(Math.abs(-1));
console.log(Math.abs('-1'));
console.log(Math.abs('Echo'));
console.log(Math.floor(1.1));
console.log(Math.floor(1.9));
console.log(Math.ceil(1.1));
console.log(Math.ceil(1.9));
console.log(Math.round(1.1));
console.log(Math.round(1.5));
console.log(Math.round(1.9));
console.log(Math.round(-1.1));
console.log(Math.round(-1.5));
</script>
</head>
<body>
</body>
</html>
1.2 时间对象
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script>
var date = new Date();
console.log(date);
var date1 = new Date(2019, 10, 1);
console.log(date1);
var date2 = new Date('2019-10-1 8:8:8');
console.log(date2);
</script>
</head>
<body>
</body>
</html>