Optional and have default value

R

ruca

Hi,

How can I set a parameter of a function optinal and have a default value?
In VB I do like this:
Function myFunction (Optional ByVal bExist as Boolean = False)

What's the equivalent in JScript?
 
M

Marina

javascript doesn't require that all the parameters defined are passed in. It
is not compiled, and the interpreter doesn't care. So if there are 5
parameters defined, the caller can pass in 0, 1, 2, 3, 4 or 5 arguments in.
So in essence, they are all optional as far as the interpreter is concerned.

As far as default values, you would have to check if a particular argument
is null, and if it, manually assign it a value in your function to have the
effect of having a default value.
 
C

Cowboy \(Gregory A. Beamer\)

No direct equivalent. Here is a FAQ on args in JScript. It is not exactly
what you are looking for, but you should be able to adopt to your needs.

http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=42

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

**********************************************************************
Think Outside the Box!
**********************************************************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top