Single-Line to Multi-Line ES6 Fat Arrow Function?

前端 未结 2 1983
南笙
南笙 2020-12-16 11:43

I\'m learning ES6 fat arrow functions. What is the correct way to change this code, so as to be able to put another line, even const a = 100; in the place indic

2条回答
  •  粉色の甜心
    2020-12-16 12:05

    If you want to convert the following method into having more lines:

    {
      filter: appointment => true
    }
    

    You have to add curly braces and a return statement:

    {
      filter: appointment => {
        // ... add your other lines here
        return true;
      }
    }
    

提交回复
热议问题