Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

javacript function meaning

Posted on 2015-02-04
2
Medium Priority
?
60 Views
Last Modified: 2015-02-05
Hi all. Maybe thi is a stupid quetion, but I would like to understand the difference between these two forms of writing functions in javascript:

var doStuff = function(){
  return stuff;
}

Open in new window


vs

function doStuff(){
  return stuff;

Open in new window


Thank you
0
Comment
Question by:Marco Gasi
2 Comments
 
LVL 34

Accepted Solution

by:
Big Monty earned 2000 total points
ID: 40589508
your first code snippet declares a variable and assigns the return value of the function to that variable.

the second code snippet still returns a value, but it's not storing the data in any variable. This method is commonly used when you just want execute some code and don't care about any return value
0
 
LVL 31

Author Closing Comment

by:Marco Gasi
ID: 40591567
Thank you for the clear explanation.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

879 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question