SlideShare a Scribd company logo
1 of 18
Introduction of JavaScript
Black 2014/08/23
1
JavaScript
• Front-End
– 網頁的”動作”
– .js
• Back-End
– NodeJS http://nodejs.org/
編輯器:Notepad++ 6.1.3 :
http://notepad-plus-plus.org/download/v6.1.3.html 2
JavaScript 語法
• 資料型態:number, string, boolean
(ex) 0xFF 1.31E-2 NaN ‘Black’ true/false
• typeof()
• 動態語言(不需宣告變數型態)
var x = [5, ‘WebII’]; x[0] x[1]
• null, undefined
• instanceof()
3
JavaScript語法
• function func() {
x = 15; //global
var y = 20; //local
}
• 弱型態語言
var result = ‘5’ – ‘3’
• toString(), valueOf(), parseFloat(), parseInt()
4
Scope Chain
var x = 10;
function outer() {
var y = 20;
function inner() {
var z = 30;
}
}
• __parent__
• Closure(擁有閒置變數的運算式)
5
JavaScript語法
• 運算子
+ - * / -- += != === && || ? : void
• 建立物件
var obj = new Object();
var obj = {};
• Constructor, Properties, Method
Car.color, Car[‘color’], Car.speedUp(30)
var Car = {
color : ‘blue',
speed : 0,
speedUp : speedUp
};
Function speedUp() {
…};
6
JavaScript語法
• Array
forEach every some filter map reduce
• for(;;) while() if()…else
• this, call(), apply()
toString.call(p1), add.apply(o1, args)
7
HTML
• 直譯式語言(不用編譯)
• .html
• Unicode (UTF-8/16/32)
• 瀏覽器開啟即可執行
8
瀏覽器直接編輯HTML
• Chrome : Ctrl + Shift + i or F12
• FireFox : 需安裝Firebug套件
• Safari : 內建是關閉的,需至開發人員選項開啟
參考資料:http://ppt.cc/xM8u 9
script 應該放在哪
<html>
<head>
<script> …. </script>
</head>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
<script> ….寫在body最後面 </script>
</body>
</html>
• DOM
Ex1.html 10
將JavaScript獨立成一個檔案
• 存成.js
• 嵌入.html
<script type="text/javascript" charset="Big5" src="./JSFile.js"></script>
• 編碼問題:瀏覽器會假設載入的.js檔案編碼
與HTML網頁編碼相同
11
Ex2.html
Ex2.js
Document Object Model (DOM)
• 描述 HTML 或 XML 文件的邏輯架構
• HTML Level 0 DOM
– Netscape
– 沒有一個統一規則,但最普遍被使用
http://www.aptana.com/reference/html/api/HTMLDOM0.index.html
• W3C DOM
– 由W3C聯合制定
http://www.w3.org/DOM/DOMTR
12
DOM
參考資料:http://www.cs.pu.edu.tw/~tsay/course/webprog/notes/DOM.html 13
屬性及特性
• 屬性:Attribute (寫程式時給定的性質)
• 特性:Property (DOM中物件原本的性質)
• <input name=“user” value=“Black”>
• 其餘未給定的DOM性質(如 type)則仍為物件的
特性
• getAttribute(String name)
• setAttribute(String name, String value)
• removeAttribute(String name)
14
取得物件
1. document.getElementByTagName(String
tagname)
2. document.getElementById(String elementID)
3. document.getElementByName(String
elementName)
• (ex)
• document.getElementById(‘ID_1’)
• <input id=“ID_1” name="x">
1 2 3
15
Ex3.html
jQuery
• JavaScript的Library
• 主要是用在 DOM 文件的操作
• jQuery 的核心程式還加強了非同步傳輸
(AJAX)以及事件(Event)的功能
Ex :
$("form").submit(function() {
if ($("input#username").val() == "")
$("span.help").show();
});
16
柯p滑出來對你說政見
• http://goooooooogle.github.io/kp/
• kp-gh-pagesindex.html
17
Reference
• W3Schools
http://www.w3schools.com/
• JavaScript Essence
http://openhome.cc/Gossip/JavaScript/
• JaveScript 教學系列
http://ithelp.ithome.com.tw/question/10098361
• 用NodeJS學JavaScript:教學
http://www.codedata.com.tw/javascript/using-nodejs-to-learn-javascript/
• https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference
18

More Related Content

Viewers also liked

Ieee 2013 2014 final year java project titles
Ieee 2013 2014 final year java project titlesIeee 2013 2014 final year java project titles
Ieee 2013 2014 final year java project titlesRICHBRAINTECH
 
2012 2013 ieee java projects richbraintechnologies
2012 2013 ieee java projects richbraintechnologies2012 2013 ieee java projects richbraintechnologies
2012 2013 ieee java projects richbraintechnologiesRICHBRAINTECH
 
Ashay Curriculum Vitae
Ashay Curriculum VitaeAshay Curriculum Vitae
Ashay Curriculum VitaeAshay Karpe
 
Ieee 2013 dotnet project titles richbraintech
Ieee 2013 dotnet project titles richbraintechIeee 2013 dotnet project titles richbraintech
Ieee 2013 dotnet project titles richbraintechRICHBRAINTECH
 
Accounting & Business
Accounting & BusinessAccounting & Business
Accounting & BusinessWilliam Clark
 
Virtual Museum II: Museum of Historical Art
Virtual Museum II: Museum of Historical ArtVirtual Museum II: Museum of Historical Art
Virtual Museum II: Museum of Historical Artjamiee_m
 
Etl testing strategies
Etl testing strategiesEtl testing strategies
Etl testing strategiessivam_1
 

Viewers also liked (9)

Ieee 2013 2014 final year java project titles
Ieee 2013 2014 final year java project titlesIeee 2013 2014 final year java project titles
Ieee 2013 2014 final year java project titles
 
2012 2013 ieee java projects richbraintechnologies
2012 2013 ieee java projects richbraintechnologies2012 2013 ieee java projects richbraintechnologies
2012 2013 ieee java projects richbraintechnologies
 
Ashay Curriculum Vitae
Ashay Curriculum VitaeAshay Curriculum Vitae
Ashay Curriculum Vitae
 
Ieee 2013 dotnet project titles richbraintech
Ieee 2013 dotnet project titles richbraintechIeee 2013 dotnet project titles richbraintech
Ieee 2013 dotnet project titles richbraintech
 
Accounting & Business
Accounting & BusinessAccounting & Business
Accounting & Business
 
made easy digital
made easy digitalmade easy digital
made easy digital
 
Virtual Museum II: Museum of Historical Art
Virtual Museum II: Museum of Historical ArtVirtual Museum II: Museum of Historical Art
Virtual Museum II: Museum of Historical Art
 
Etl testing strategies
Etl testing strategiesEtl testing strategies
Etl testing strategies
 
Class 13
Class 13Class 13
Class 13
 

Similar to Java script

模块一-Go语言特性.pdf
模块一-Go语言特性.pdf模块一-Go语言特性.pdf
模块一-Go语言特性.pdfczzz1
 
JavaScript 物件導向觀念入門 v.s. TypeScript 開發實戰 (微軟實戰課程日)
JavaScript 物件導向觀念入門 v.s. TypeScript 開發實戰 (微軟實戰課程日)JavaScript 物件導向觀念入門 v.s. TypeScript 開發實戰 (微軟實戰課程日)
JavaScript 物件導向觀念入門 v.s. TypeScript 開發實戰 (微軟實戰課程日)Will Huang
 
Node.js在淘宝的应用实践
Node.js在淘宝的应用实践Node.js在淘宝的应用实践
Node.js在淘宝的应用实践taobao.com
 
Java Jdk6学习笔记[Ppt]
Java Jdk6学习笔记[Ppt]Java Jdk6学习笔记[Ppt]
Java Jdk6学习笔记[Ppt]yiditushe
 
D2_node在淘宝的应用实践_pdf版
D2_node在淘宝的应用实践_pdf版D2_node在淘宝的应用实践_pdf版
D2_node在淘宝的应用实践_pdf版Jackson Tian
 
EventProxy introduction - JacksonTian
EventProxy introduction - JacksonTianEventProxy introduction - JacksonTian
EventProxy introduction - JacksonTianJackson Tian
 
Event proxy introduction
Event proxy introductionEvent proxy introduction
Event proxy introductionmysqlops
 
Javascript primer plus
Javascript primer plusJavascript primer plus
Javascript primer plusDongxu Yao
 
Baidu LSP and DISQL for Log Analysis
Baidu LSP and DISQL for Log AnalysisBaidu LSP and DISQL for Log Analysis
Baidu LSP and DISQL for Log AnalysisXiaoming Chen
 
Linux binary Exploitation - Basic knowledge
Linux binary Exploitation - Basic knowledgeLinux binary Exploitation - Basic knowledge
Linux binary Exploitation - Basic knowledgeAngel Boy
 
一拍一产品背后的故事(React实战)
一拍一产品背后的故事(React实战)一拍一产品背后的故事(React实战)
一拍一产品背后的故事(React实战)Kejun Zhang
 
2016年逢甲大學資訊系:ASP.NET MVC 4 教育訓練3
2016年逢甲大學資訊系:ASP.NET MVC 4 教育訓練32016年逢甲大學資訊系:ASP.NET MVC 4 教育訓練3
2016年逢甲大學資訊系:ASP.NET MVC 4 教育訓練3Duran Hsieh
 
潜力无限的编程语言Javascript
潜力无限的编程语言Javascript潜力无限的编程语言Javascript
潜力无限的编程语言Javascriptjay li
 
Ecma script edition5-小试
Ecma script edition5-小试Ecma script edition5-小试
Ecma script edition5-小试lydiafly
 
KISSY for starter
KISSY for starterKISSY for starter
KISSY for starteryiming he
 

Similar to Java script (20)

模块一-Go语言特性.pdf
模块一-Go语言特性.pdf模块一-Go语言特性.pdf
模块一-Go语言特性.pdf
 
JavaScript 物件導向觀念入門 v.s. TypeScript 開發實戰 (微軟實戰課程日)
JavaScript 物件導向觀念入門 v.s. TypeScript 開發實戰 (微軟實戰課程日)JavaScript 物件導向觀念入門 v.s. TypeScript 開發實戰 (微軟實戰課程日)
JavaScript 物件導向觀念入門 v.s. TypeScript 開發實戰 (微軟實戰課程日)
 
Jasmine
JasmineJasmine
Jasmine
 
Node.js在淘宝的应用实践
Node.js在淘宝的应用实践Node.js在淘宝的应用实践
Node.js在淘宝的应用实践
 
Java Jdk6学习笔记[Ppt]
Java Jdk6学习笔记[Ppt]Java Jdk6学习笔记[Ppt]
Java Jdk6学习笔记[Ppt]
 
D2_node在淘宝的应用实践_pdf版
D2_node在淘宝的应用实践_pdf版D2_node在淘宝的应用实践_pdf版
D2_node在淘宝的应用实践_pdf版
 
EventProxy introduction - JacksonTian
EventProxy introduction - JacksonTianEventProxy introduction - JacksonTian
EventProxy introduction - JacksonTian
 
Event proxy introduction
Event proxy introductionEvent proxy introduction
Event proxy introduction
 
Javascript primer plus
Javascript primer plusJavascript primer plus
Javascript primer plus
 
Baidu LSP and DISQL for Log Analysis
Baidu LSP and DISQL for Log AnalysisBaidu LSP and DISQL for Log Analysis
Baidu LSP and DISQL for Log Analysis
 
Linux binary Exploitation - Basic knowledge
Linux binary Exploitation - Basic knowledgeLinux binary Exploitation - Basic knowledge
Linux binary Exploitation - Basic knowledge
 
一拍一产品背后的故事(React实战)
一拍一产品背后的故事(React实战)一拍一产品背后的故事(React实战)
一拍一产品背后的故事(React实战)
 
Berserk js
Berserk jsBerserk js
Berserk js
 
2016年逢甲大學資訊系:ASP.NET MVC 4 教育訓練3
2016年逢甲大學資訊系:ASP.NET MVC 4 教育訓練32016年逢甲大學資訊系:ASP.NET MVC 4 教育訓練3
2016年逢甲大學資訊系:ASP.NET MVC 4 教育訓練3
 
Json知识分享
Json知识分享Json知识分享
Json知识分享
 
Javascript
JavascriptJavascript
Javascript
 
潜力无限的编程语言Javascript
潜力无限的编程语言Javascript潜力无限的编程语言Javascript
潜力无限的编程语言Javascript
 
Node分享 展烨
Node分享 展烨Node分享 展烨
Node分享 展烨
 
Ecma script edition5-小试
Ecma script edition5-小试Ecma script edition5-小试
Ecma script edition5-小试
 
KISSY for starter
KISSY for starterKISSY for starter
KISSY for starter
 

Java script

Editor's Notes

  1. AJAX : 內容更新時不用重新加載整個網頁,可部分加載