????

1 / 8

# ???? - PowerPoint PPT Presentation

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

## PowerPoint Slideshow about '????' - deanna

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

### 認識物件

Javascript內建物件分為三大類

• 通常製造一個字串物件，最簡單的方法是指定一個文字常數給一個變數。
• 例：test=“this is a test”
• 常見的屬性或方法

length bold fontsize toLowerCase toUpperCase

• 使用方法 : 物件名.方法(參數值)
• 範例 :

document.write (test.length) 顯示字串長度

document.write (test. fontsize(20)) 顯示字串為20號字

<script language="javascript">

var test ="This is a test !"

document.write ("<p>"+test.length)

document.write ("<p>"+test.bold())

document.write ("<p>"+test.fontsize(20))

document.write ("<p>"+test.toLowerCase())

document.write ("<p>"+test.toUpperCase())

</script>

• 數學物件主要是幫助你做一些數學運算。
• 例：Math.pow(2,2) => 4
• 常見的屬性或方法

abs floor max min pow sqrt random()

• 使用方法 : 物件名.方法(參數值)
• 範例 :

document.write (Math.pow(2,2)) 2的平方為4

document.write (Math.random()) 取亂數

• 日期物件是來幫助你處理日期。
• 例：var d1=new Date()
• 常見的屬性或方法

getDate getDay getHours getMinute getTime

getYear getSeconfs getMonth

• 範例 :

document.write (d1.getYear) 顯示年份

document.write (d1.getMonth) 顯示月份

<script language="javascript">

today=new Date()

date1=new Date("December 25,2004 ,11:00")

date2=new Date(2004,3,18)

document.write ("<p>"+today.toGMTString())

document.write ("<p>"+today.toLocaleString())

document.write ("<p>"+date1.toLocaleString())

document.write ("<p>"+date2.toLocaleString())

</script>