0

There are different structure of create function in node.js. Like :

function abc(){
       console.log('stackoverflow');
    }

Is there any new format available and is it usefull?

1
  • 2
    Your question suggests lack of research. Node.js relies on JavaScript, all syntax was inherited from it. Commented Sep 9, 2016 at 10:17

2 Answers 2

4

Method#1

function test(){}; // function declaration

Method#2

var test = function(){};  // function expression

Method#3

var abc = function test(){};   // named function expression

Method#4

var test = (function(){        // IIFE that returns a function
  return function(){}
})();

Method#5

var Test = new Function();     // Function constructor

Method#6

var Test = a => a * 2;     // ES6 arrow function
Sign up to request clarification or add additional context in comments.

Comments

2

That is the format till EcmaScript 6.

Then, to declare a function, you can use:

let result = abc => console.log('stackoverflow');

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.