# Math對象
是一個固有對象,提供基本數學函數和常數。
## round方法 四舍五入
~~~
<script>
console.log(Math.round(2.5)); // 3
console.log(Math.round(2.4)); // 2
</script>
~~~
## random方法 返回0~1之間的隨機數
~~~
<script>
console.log(Math.random()); // 0.14340542373247445
console.log(parseInt(Math.random() * 10)); // 返回0~10之間的隨機數
</script>
~~~
## max方法 返回最高值
~~~
<script>
console.log(Math.max(1,0.5,23,111,222,231)); // 231
</script>
~~~
## min方法 返回最低值
~~~
<script>
console.log(Math.min(1,0.5,23,111,222,231)); // 0.5
</script>
~~~
## abs方法 返回絕對值
~~~
<script>
console.log(Math.abs(-1.23)); // 1.23
</script>
~~~
- 空白目錄
- JavaScript保留字
- JS事件
- JS面向對象
- JS內置對象
- 自定義對象
- String 字符串對象
- Date 日期時間對象
- Array 數組對象
- Math 對象
- DOM對象控制HTML
- getElementsByName
- getElementsByTagName
- getAttribute 獲取元素屬性
- setAttribute 設置元素屬性
- childNodes 訪問子節點
- parentNode 訪問父節點
- createElement 創建元素節點
- createTextNode 創建文本節點
- insertBefore 插入節點
- removeChild 刪除節點
- offsetHeight 網頁高度
- scrollHeight 網頁高度
- JS瀏覽器對象
- window對象
- 計時器
- history對象
- location對象
- screen對象
- navigator對象
- 彈出窗口
- cookies