亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

首頁課程Javascript fun classMath object

Math object

目錄列表

Math 對象

Math 對象

Math(算數(shù))對象的作用是:執(zhí)行普通的算數(shù)任務(wù)。

Math 對象提供多種算數(shù)值類型和函數(shù)。無需在使用這個(gè)對象之前對它進(jìn)行定義。

Math 對象屬性


document.write(Math.PI); 
// -> 3.141592653589793

提示: Math 沒有構(gòu)造函數(shù)。沒有必要先創(chuàng)建一個(gè)Math對象。


在 Math 對象中,以下哪些常量不存在?

Math 對象方法

Math 對象方法

Math對象包含許多用于計(jì)算的方法:


例如,以下將計(jì)算一個(gè)數(shù)字的平方根。

var number = Math.sqrt(4); 
document.write(number);
// -> 2


在 Math 對象中,使用以下哪種方法計(jì)算平方根?

Math 對象

Math 對象

讓我們創(chuàng)建一個(gè)程序,讓用戶輸入一個(gè)數(shù)字并通過提醒顯示平方根。

var n = prompt("請輸入一個(gè)數(shù)字:", "");
var answer = Math.sqrt(n);
alert("數(shù)字" + n + " 的平方根是: " + answer);


輸入64,點(diǎn)確定

 

以下表達(dá)式的結(jié)果是什么?

Math.sqrt(81);