All services fromyour imperative.
6
JavaScript 的型別概念
JavaScript 是一種動態型別的語言
var x;
var x = 5;
var x = "John";
var carname="Volvo";
var carname;
這種變數型別又稱「弱型別」 (Weak Type)
7.
All services fromyour imperative.
7
JavaScript 的物件概念
JavaScript 物件,僅包含屬性與方法
var car = new Object();
屬性
car.name = "BMW";
方法
car.start();
"Everything" in JavaScript is an Object!
var txt = "Hello World";
txt.length
txt.indexOf('World');
8.
All services fromyour imperative.
8
JavaScript 的物件概念
JavaScript 如何建立一個物件
var car = new Object();
car.name = "BMW";
car.start = function() {
return true;
}
Object - JavaScript | MDN
9.
All services fromyour imperative.
9
隨堂測驗 (1)
請回答以下問題:
var o1 = 'Hello World';
var o2 = new String('Hello World');
o1 == o2
o1 === o2
typeof o1
typeof o2
10.
All services fromyour imperative.
10
隨堂測驗 (2)
以下陳述式是否會發生例外?
var car = 'Hello World';
car.name = "BMW";
car.start = function() {
return true;
}
car.start();
11.
All services fromyour imperative.
11
隨堂測驗 (3)
以下陳述式是否會發生例外?
var car = new String('Hello World');
car.name = "BMW";
car.start = function() {
return true;
}
car.start();
12.
All services fromyour imperative.
12
隨堂測驗 (4)
以下陳述式 txt.name 結果為何?
var car = 'Hello World';
String.prototype.name = "BMW";
String.prototype.start = function()
{
return true;
}
var txt = 'Will';
txt.name
13.
All services fromyour imperative.
13
隨堂測驗 (5)
以下陳述式 txt.name 結果為何?
var car = new String('Hello World');
String.prototype.name = "BMW";
String.prototype.start = function()
{
return true;
}
var txt = 'Will';
txt.name
14.
All services fromyour imperative.
14
JavaScript 的函數概念
JavaScript 如何建立一個函數 (1)
function HelloWorld()
{
return "Hello World";
}
All services fromyour imperative.
40
善用 TypeScript 工具支援
Visual Studio 2012
自動型別檢查 (Static type checking)
隱含強型別推演 (Strong type inference)
移至定義 (Go To Definition) ( F12 )
巡覽至 (Navigate To) ( Ctrl + , )
語法自動完成 / Intellisense ( Ctrl + j )
程式碼重構 (Code refactoring) ( F2 )
下載: TypeScript for Visual Studio 2012 ( v0.8.1.1 )
Monaco (線上版編輯器)
http://www.typescriptlang.org/Playground/
37.
All services fromyour imperative.
41
TypeScript 的工具支援
TypeScript support for Sublime Text
http://www.interoperabilitybridges.com/media/15545
2/typescript_support_for_sublime_text.zip
TypeScript support for Emacs
http://www.interoperabilitybridges.com/media/15544
9/typescript_support_for_emacs.zip
TypeScript support for Vim
http://www.interoperabilitybridges.com/media/15544
6/typescript_support_for_vim.zip
All services fromyour imperative.
50
聯絡資訊
The Will Will Web
記載著 Will 在網路世界的學習心得與技術分享
http://blog.miniasp.com/
Will 保哥的技術交流中心 (臉書粉絲專頁)
http://www.facebook.com/will.fans
★ ★ ★ Will 保哥的噗浪 ★ ★ ★
http://www.plurk.com/willh/invite
#55 No expectations upon youWe invite you to join activitiesMicrosoft has no expectations of MVPs beyond courtesy, professionalism, and adherence to the rules of conduct (https://mvp.support.microsoft.com/default.aspx/codeofconduct)Remember the Non-Disclosure Agreement