Why Study JavaScript?
JavaScript is one of the 3 languages all web developers must learn:
- HTML to define the content of web pages
- CSS to specify the layout of web pages
- JavaScript to program the behavior of web pages
what is JavaScript can do?
-
Change HTML Content
Example
document.getElementById("demo").innerHTML = "Hello JavaScript"; -
Change HTML Attributes
-
Change HTML Styles (CSS)
Example
document.getElementById("demo").style.fontSize = "25px"; -
Can Validate Data(驗証資料)
JavaScript Where To
- (比較不負責任說法)簡單的來說就是隨便放,不過大多數專家習慣放head之間或獨立一JS檔,引入使用。
Keeping all code in one place, is always a good habit. - 其實要注恴是瀏覽器解析HTML的流程及JavaScript的解析流程,JS放置的位置會影響到使用中的函數是否會調用到未被定義的值而發生錯誤。
JavaScript Output
- JavaScript does not have any built-in print or display functions.
JS沒有任何自有的輸出/打印的函數
JavaScript Display Possibilities
JavaScript can "display" data in different ways:
- Writing into an alert box, using window.alert().
//出跳出警示視窗。- Writing into the HTML output using document.write().
// will delete all existing (己解析的內容,全清除出)- Writing into an HTML element, using innerHTML.
//選取HTML元素中的innerHTML屬性,就是元素的內文區塊。- Writing into the browser console, using console.log(). 瀏覽器控制台
JavaScript Comments註解
// | 單行:符號後至行結束。不需放在行最前頭。 |
/* 註解區塊 */ | 多行: /*這個型態符號很容易與HTML混在一起,造成程式碼解譯上的錯誤。能少用就少用。 不過這個在其它語言,幾乎是註解符號的標準了! |
JavaScript is Case Sensitive(區分大小寫)
All JavaScript identifiers are case sensitive.
The variables lastName and lastname, are two different variables.
JavaScript and Camel Case
當語言可區分大小寫時,在設定「識別名稱ID」上,程序開發會有些習慣用法:
- 變數名稱:
- 函數名稱:
- 常數名稱:
JavaScript Character Set
JavaScript uses the Unicode character set.
Unicode covers (almost) all the characters(字元/符), punctuations(標點), and symbols(符號) in the world.
字元集的詳細學習可以到W3shool查看(Complete Unicode Reference.)
詳細內容可以參考:
- w3school.com (http://www.w3schools.com/)
-
程式語言教學誌(http://pydoing.blogspot.tw/)
沒有留言:
張貼留言