How to write function | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to write function

are these 2 codes the same: var myFunction = function () {code} as function = myFunction () {code} If so how do you write and why?

21st Oct 2016, 9:26 PM
ajkuly
5 Answers
+ 11
easy way to define functions, function functionNAME (); { //any content };
26th Oct 2016, 1:15 PM
Saurav Saini
Saurav Saini - avatar
+ 2
Check this out. I can't explain it as well as they do in this post, hopefuly clears it up a little for you. http://stackoverflow.com/questions/336859/javascript-function-declaration-syntax-var-fn-function-vs-function-fn
22nd Oct 2016, 10:41 AM
Pink Lemonade
+ 1
Thx for the answer and link. Stackoverflow is always great resource. The answer to the question is little more complicated than I tought. Have to read the answers again.
22nd Oct 2016, 11:32 AM
ajkuly
+ 1
functions are 2 types some of them don't return any value and just manipulate some data, others do return value. if your function returns value u could assign that value to a variable but u can't assign that value directly to a function, u must feed your function with parameters "function('parameter/s')".😊
22nd Oct 2016, 8:21 PM
babakm
babakm - avatar
+ 1
use the sololearn JavaScript Tutorials! its really helpful! 👌
10th Aug 2017, 3:07 PM
David Ajaba
David Ajaba - avatar