Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Javascript_基礎二.pdf

 Javascript_基礎二.pdf

darrenyaoyaoyao

October 27, 2020
Tweet

More Decks by darrenyaoyaoyao

Other Decks in Programming

Transcript

  1. for 迴圈 for (var i = 0 ; i <

    5 ; i++) {
 …
 }
  2. for ( 語法⼀ ; 語法⼆ ; 語法三) {
 …
 }

    語法⼀ : 初始條件 語法⼆ : 結束條件 語法三 : 每次回圈都要執⾏的程式
  3. for 迴圈其實是程式碼的縮寫 for (var i = 0 ; i <

    5 ; i++) {
 console.log(“Hello”)
 } console.log(“Hello”)
 console.log(“Hello”)
 console.log(“Hello”)
 console.log(“Hello”)
 console.log(“Hello”)
  4. array 陣列 var a = [“12”, “23”, “4”] a[0] =

    “12” a[1] = “23” a[2] = “4”
  5. array 陣列常⽤⼦函式 var a = [“12”, “23”, “4”] a.length //

    指 a 的長度 a.push(“56”) // 在尾巴新增內容
  6. object 物件 var david = { age: 12,
 weight: 70

    } david.age = 12
 david.weight = 70
  7. object 物件 var david = { age: 12,
 weight: 70

    } david.age = 12
 david.weight = 70
  8. object 物件 var david = { age: 12,
 weight: 70

    } 我們會稱
 age 為 key
 12 為 value
  9. object 物件 var david = { age: 12,
 weight: 70

    } key 可以為任意英⽂字或字串
 value 可以為任何型態
 包括 function, arrary, object