ES6 箭頭函式

2021-08-19 06:07:44 字數 515 閱讀 6507

es6 中,箭頭函式就是函式的一種簡寫形式,使用括號包裹數,跟隨乙個 =>,緊接著是函式體:

var getprice = function

()// 箭頭函式

var getprice = () => 9.15;

箭頭函式不僅僅是讓**變得簡潔,函式中 this 總是繫結總shi 指向物件自身

function

person

() , 1000);

}

使用箭頭函式可以免去這個麻煩

function person(), 1000);

}

為什麼會突然發現這個東西呢,在學習vue的時候遇到,在宣告vue時候

methods:);

}}

methods:);

}}

兩者的作用一致

es6箭頭函式

本例是在了解es6知識後在原來定義函式的基礎上進行理解var searchvalue 查詢匹配物件 var button var input var select button if searchvalue.input undefined button.click else 重新整理 tableli...

es6 箭頭函式

1.單引數 function cheng a 3 let cheng a 3 a a console.log cheng 9 2.多引數 function add a,b let add a,b a b 預設返回值 console.log add 3,9 3.無返回值 function add a,...

ES6箭頭函式

語法 param param param expression使用 零個引數用 表示 x 乙個引數,可以省略 x,y 多個引數不能省略 多行語句需要用 括起來,單行表示式不需要 並且會作為函式返回值。特性 箭頭函式內部沒有constructor方法,也沒有prototype,所以不支援new操作。但...