[day-2] JS 環境建立流程/賦值運算子

xiang
Oct 20, 2021

網頁與 Code 環境建立流程

  1. 建立一支all.js檔案
  2. 在html的內容輸入<script src”路徑/all.js”> </script>來載入js檔案

console.log /alert 印出資訊

console.log( )印出目前資料 / alert( )彈出視窗

let a = 1;

let b = 2;

console.log(a,b);

console.log(b);

alert(a);

則會輸出1 2,2和彈出視窗顯示1

JavaScript的註解

單行註解,寫在兩個(正)斜線「//」之後,例如: // 我是一個註解

多行註解:寫在/* 和*/ 之間的文字,例如: /* 我也是一個註解*/

賦值運算子

加法賦值x = x + y 可以寫為 x += y

減法賦值x = x — y可以寫為x -= y

乘法賦值 x = x * y可以寫為x *= y

除法賦值x = x / y可以寫為x /= y

a++、a- -

a++:幫a變數+1

a- -幫a變數 - 1

--

--

xiang
0 Followers

Front-end self-taught college students