logo
  • 教程列表
  • SO官方文檔
  • Node.js v6 新功能和改進
    • 預設功能引數
    • 休息引數
    • 傳播運算子
    • 箭頭函式
    • 這是箭頭函式
  1. StackOverflow 文件
  2. Node.js 教程
  3. Node.js v6 新功能和改進
  4. 箭頭函式

箭頭函式

Created: November-22, 2018

箭頭函式是在 ECMAScript 6 中定義函式的新方法。

// traditional way of declaring and defining function
var sum = function(a,b)
{
    return a+b;
}

// Arrow Function
let sum = (a, b)=> a+b;

//Function defination using multiple lines 
let checkIfEven = (a) => {
    if( a % 2 == 0 )
        return true;
    else
        return false;
}
  • 這是箭頭函式
  • 傳播運算子

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 關於本站
  • 免責聲明