week10.md - Paouser/wp109b GitHub Wiki
-
- 設定輸入字元 let e = Deno.args[0]
- 設定某字元為函數
- function look (e) { return e; }
- let c = look(e);
- 浮點數
- var a=0.3 , b=0.1+0.2;
- a-b == 0 is false
- a-b<0.1 is true
- 不要比較兩個浮點數是否相等!
-
- 取出物件索引值
- 設定物件 var george = { 'friends':[
- { 'name' : 'John' , 'age' : 22 }
- { 'name' : 'Mary' , 'age' : 28 } ] }
- 執行迴圈 for ( let i in friends )
- ( 如果迴圈執行第一次 ) friends[i].name = John
- ( 迴圈第二次 ) friends[i].name = Mary
- 宣告函數
- 使用( class )
- class User(name) { constructor(name) { this.name = name ; }
- sayHi() { console.log( this.name ); } }
- 使用( function )
- function User(name) { this.name = name; }
- User.prototype.sayHi = function() { console.log( this.name ); }
- 繼承類別 extends
- class Animal { say() {} }
- class Dog extends Animal { say() { console.log('旺旺') } }
- class cat extends Animal { say() { console.log('喵喵') } }
- 呼叫函數 var animalList = [a,b]
- 多形 for ( var x of animalList) { x.say() }
⚠️ **GitHub.com Fallback** ⚠️