国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

首頁課程Javascript fun classMath object

Math object

目錄列表

Math 對(duì)象

Math 對(duì)象

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

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

Math 對(duì)象屬性


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

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


在 Math 對(duì)象中,以下哪些常量不存在?

Math 對(duì)象方法

Math 對(duì)象方法

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


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

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


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

Math 對(duì)象

Math 對(duì)象

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

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


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

 

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

Math.sqrt(81);