Solved

javacript function meaning

Posted on 2015-02-04
2
54 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 32

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
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…

910 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now