Solved

javacript function meaning

Posted on 2015-02-04
2
57 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 33

Accepted Solution

by:
Big Monty earned 500 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How do I Enable submit button only if listbox has items 4 64
Change javascript filter code from OR logic to AND 5 41
Conformation code 4 37
Natural height and jquery 6 40
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.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…

752 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