Queston about " function ".. #confusion


#1

there are two ways of making a function i've learnt so far in this course...

first:
function me(){
//....
};
second:
var me = function(){
///....
}
now my question is when to make function by "first" method and "second" method
@leonhard_wettengmx_n


#2

The first way is typically used in constructors of custom Objects, the second is a convention for functions of all other uses. Leave a reply with any questions please! :smile:


#3

so we can't make a constructor or class by using this:

var me = function(){};
@cadecodes


#4

No, that is not the typical convention.


#5

@devace03046,

Found with google search
== discussions / opinions ==
javascript var function vs named function site:stackoverflow.com
= http://stackoverflow.com/questions/336859/var-functionname-function-vs-function-functionname?rq=1

=discussions=
javascript return statement site:stackoverflow.com
= http://stackoverflow.com/questions/3717420/is-there-a-benefit-to-using-a-return-statement-that-returns-nothing
= http://stackoverflow.com/questions/22134753/return-statement-in-javascript

=closure scope hoisting=
https://www.codecademy.com/forum_questions/54936d24e39efeeb1d000111#comment-5499a6ea9113cbdac9009bb0
https://www.codecademy.com/forum_questions/55d0b0c7937676b904000522