有没有其他的方法来创buildnode.jsfunction
node.js中的创build函数有不同的结构。 喜欢 :
function abc(){ console.log('stackoverflow'); }
有没有新的格式,是否有用?
方法1
function test(){}; // function declaration
方法2
var test = function(){}; // function expression
方法#3
var abc = function test(){}; // named function expression
方法#4
var test = (function(){ // IIFE that returns a function return function(){} })();
方法#5
var Test = new Function(); // Function constructor
方法#6
var Test = a => a * 2; // ES6 arrow function
这是直到EcmaScript 6的格式。
然后,要声明一个函数,你可以使用:
let result = abc => console.log('stackoverflow');