473,387 Members | 1,545 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Optional and have default value

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?
--
Programming ASP.NET with VB.NET
Thank's (if you try to help me)
Hope this help you (if I try to help you)
ruca
Nov 18 '05 #1
3 1314
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.

"ruca" <ru***@iol.pt> wrote in message
news:O3**************@TK2MSFTNGP12.phx.gbl...
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?
--
Programming ASP.NET with VB.NET
Thank's (if you try to help me)
Hope this help you (if I try to help you)
ruca

Nov 18 '05 #2
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!
************************************************** ********************
"ruca" <ru***@iol.pt> wrote in message
news:O3**************@TK2MSFTNGP12.phx.gbl...
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?
--
Programming ASP.NET with VB.NET
Thank's (if you try to help me)
Hope this help you (if I try to help you)
ruca

Nov 18 '05 #3
By the way, I was talking about client side jscript...

"Marina" <so*****@nospam.com> wrote in message
news:O5**************@TK2MSFTNGP09.phx.gbl...
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.

"ruca" <ru***@iol.pt> wrote in message
news:O3**************@TK2MSFTNGP12.phx.gbl...
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?
--
Programming ASP.NET with VB.NET
Thank's (if you try to help me)
Hope this help you (if I try to help you)
ruca


Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Gerry Abbott | last post by:
Hi All, Im trying to use thie combination but have not had success. Below is the function It tried the following myriskLevel(2,2) myrisklevel(0,0,2) and the ismissing(Three) alwasy...
14
by: cody | last post by:
I got a similar idea a couple of months ago, but now this one will require no change to the clr, is relatively easy to implement and would be a great addition to C# 3.0 :) so here we go.. To...
2
by: Oenone | last post by:
In our applications, we use the special value of DateTime.MinValue to represent "null dates" throughout all our code. We recently ran into an issue where we wanted an optional date parameter for a...
12
by: pamelafluente | last post by:
Hi guys, In the past I have used several time optional parameters in my function. But Now I am more inclined to think that they are more dangerous than useful, and probably better to be...
7
by: jamesclose | last post by:
My problem is this (apologies if this is a little long ... hang in there): I can define a function in VB.NET with optional parameters that wraps a SQL procedure: Sub Test(Optional ByVal Arg1...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.