+ 2

4 ways to declare functions in JavaScript, which best one to use?

27th Oct 2020, 1:32 PM
Andro Di Stefano
Andro Di Stefano - avatar
3 ответов
+ 4
JavaScript code that forms the function body. The list of parameters. The variables accessible from the lexical scope. The returned value.
27th Oct 2020, 1:59 PM
Matias
Matias - avatar
+ 2
The statement function is best to use in javascript. The most advantage of this type of function is that you can call a function statement before it is declared. Ex:- you can do this like, 1) Function add(n1,n2){ //code } add(2,3); or 2) add(2,3); Function add(n1,n2){ //code } Both are accepted. Hope you get it.
28th Oct 2020, 5:05 AM
Shaili Shah
Shaili Shah - avatar
+ 1
I use the traditional way function name(attr) { // code }
27th Oct 2020, 1:34 PM
Nico Ruder
Nico Ruder - avatar