Google Answers Logo
View Question
 
Q: "computer programming in JavaScript" ( Answered,   0 Comments )
Question  
Subject: "computer programming in JavaScript"
Category: Computers
Asked by: lady6-ga
List Price: $2.00
Posted: 05 Dec 2004 12:04 PST
Expires: 04 Jan 2005 12:04 PST
Question ID: 438436
In an error free JavaScript program can you have a function definition
without a call to it?
Answer  
Subject: Re: "computer programming in JavaScript"
Answered By: efn-ga on 05 Dec 2004 15:02 PST
 
Hi lady6,

Yes, you can have an unused function in an error-free JavaScript
program.  Nothing requires that a JavaScript function ever be called,
nor that there be something that calls it, whether executed or not. 
This is consistent with the requirements for functions in most, if not
all, other programming languages.

A JavaScript interpreter will not object to an unused function, and
the function definition will not cause other script elements to
malfunction.

Conceivably, if you defined an unused function as an error, a script
with an unused function could not be error-free by definition, but I
guess you would not have asked the question if you were making that
assumption.

--efn
Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy