Solved

javacript function meaning

Posted on 2015-02-04
2
53 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 30

Author Closing Comment

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

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

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 …
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…

759 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

23 Experts available now in Live!

Get 1:1 Help Now