1.JS特點(diǎn):
????解釋性腳本語(yǔ)言
????運(yùn)行在瀏覽器(瀏覽器內(nèi)核帶有js解釋器,Chrome v8引擎)
????弱類(lèi)型語(yǔ)言(松散型)
????事件驅(qū)動(dòng)(動(dòng)態(tài))
????跨平臺(tái)的腳本語(yǔ)言
2.JS書(shū)寫(xiě)位置:
????內(nèi)部js:<script>? document.write("hello world")??</script>????? 內(nèi)部引入:<script src="path:to/index.js"></script>
????外部js: index.js文件? ?document.write("hello world");
?????注意:
? ? ? ? ? 1. script標(biāo)簽可以放在頁(yè)面任何位置
? ? ? ? ? 2.下面這樣寫(xiě)是錯(cuò)誤的?。?!
? ? ? ? ? ? ? ??<script?src="path:to/index.js">??
?? ????????????????? ?document.write("hello world")??
? ? ? ? ? ? ? ? </script>
3.怎樣直觀地區(qū)分不同的數(shù)據(jù)類(lèi)型那?
?????一個(gè)關(guān)鍵字 (typeof)
? ? ?3.1????typeof返回有六種值: number、string、boolean、undefined、object(數(shù)組也是對(duì)象)、function
? ?3.2????js有五種基本數(shù)據(jù)類(lèi)型:number、string、boolean、undefined、null、symbol
? ?3.3????兩種引用類(lèi)型:object、function
? ?3.4????兩種特殊數(shù)據(jù)類(lèi)型: null、undefined
4.顯式轉(zhuǎn)換
? ? ? parseInt()、parseFloat()、Number()、toString()、String()
??????toFixed()保留幾位小數(shù)之后數(shù)據(jù)類(lèi)型變?yōu)樽址?/h4>5.四舍五入
? ? 5.1????Math.round(21.65) == 22? 不保留小數(shù)位四舍五入
? ?5.2? ? ?var a=25.546544;? ?console.log(a.toFixed(3))? ?可隨意保留小數(shù)位