let 與 const 與 Arrow Function


Posted by cmtilo on 2021-05-03

宣告變數的新選擇:let 與 const

用法就跟var一樣,letconstant的生存範圍只在{ }。
const是指constant,是常數,不會變。
盡量用let,因為寫程式時,作用域範圍越小越好,不會去影響到其他也容易debug。

箭頭函式 Arrow Function

const test = (n) => { return n }

例如

var arr = [1,2,3,4,5]
arr
 .filter(funcion(value){
  return value >1
 })
 .map(function(value){
  return value *2
 })

可簡化成

arr
 .filter(value => value>1)
 .map(value=> value *2)

#let #const #arrowfunction







Related Posts

[第一週] 認識 Command Line

[第一週] 認識 Command Line

專題研討心得:Our brawling love for information technologies in the context of XAI(臺大資管系 畢南怡 助理教授)

專題研討心得:Our brawling love for information technologies in the context of XAI(臺大資管系 畢南怡 助理教授)

Linux Curl Command 指令與基本操作入門教學

Linux Curl Command 指令與基本操作入門教學


Comments