473,399 Members | 3,106 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,399 software developers and data experts.

get info about return value for a function is wanted or not?

Hi...

I want to know (inside a function) if the calling code wants a return
value or not.

Here is an example:
function foo()
{
alert(return_wanted()); // "return_wanted" is just a name of the
function I search...
}

x=foo();

foo();
which should give "true" in the first case and "false" in the second.

An according function in perl is called "wantarray", which gives
"undef" if no return value is wanted.

Is there anything like this in javascript?

Thanks for any help in advance,

Christoph Bergmann

Jul 25 '06 #1
2 1304
in**@baseportal.de wrote in comp.lang.javascript:
Hi...

I want to know (inside a function) if the calling code wants a return
value or not.
You probably mean to say if the calling code can expect a return value to
the called function.

>
Here is an example:
function foo()
{
alert(return_wanted()); // "return_wanted" is just a name of the
function I search...
}

x=foo();
Since foo() returns no value, 'x' should be undefined.
>
foo();
which should give "true" in the first case and "false" in the second.

You mean to assign a value TRUE and FALSE? To what?

The function alert() is technically not defined in Javascript core.

An according function in perl is called "wantarray", which gives
"undef" if no return value is wanted.

Is there anything like this in javascript?
Should you want to evaluate the status of an identifier (a name for a
variable or function or object), use the typeof() operator, which returns
a string describing what you probably want. This might be especially
useful if the identifier is a variable used to hold the return value of a
called function, if there is one.


Jul 25 '06 #2
in**@baseportal.de wrote in news:1153853290.608498.252390
@m79g2000cwm.googlegroups.com:
I want to know (inside a function) if the calling code wants a return
value or not.
Maybe something like this:

rtnval = false; // if you don't want a return value
// or true, if you want a return value

function foo() {
if (rtnval) {
return 42;
}else{
return;
}
}
theval = foo(); // get a return value

alert(theval); // show it

Jul 25 '06 #3

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

Similar topics

5
by: Murat Tasan | last post by:
so i have a situation that i know cannot be solved directly, and i've already worked around it, but i was hoping to find an explanation as to why this behavior is as it is... i have an abstract...
3
by: Varun | last post by:
Hi There, I have a form("myRequest.asp") and the values from it are retrieved into the page ("output_Print.asp") on which I have two buttons('Save As Complete' and 'Save As Incomplete'). When the...
19
by: Christian Engström | last post by:
If you have a function that returns something by value, the gcc compiler (version 3.2.3 on Windows XP with MinGW) converts the returned value from the type you specify in the code, to the const...
8
by: aundro | last post by:
Hello all, I was wondering whether I could do something like: --snip-- MyType.prototype.myProp = {var xxx = 'this is a string'; xxx.substring(4);} --snip--
2
by: Chris | last post by:
I think I already know that the answer is that this can't be done, but I'll ask anyways. Suppose you want to use an RDBMS to store messages for a threaded message forum like usenet and then...
4
by: Shannan Casteel via AccessMonster.com | last post by:
I would like to be able to use 4 text boxes (i.e. Part #, Description, Quantity, Price) for up to 40 parts. However, only the Part # and Quantity will be entered. The Description and Price will...
2
by: Chris Tillotson | last post by:
Hello, I just wanted to suggest this as an idea and get feedback if it is a lame. I had a simple challenge. In my app a client can upload a file and it took a while and I wanted to indicate to the...
12
by: Rob | last post by:
Let's say you open Form1 that contains TabControl1 There are several tabs on TabControl1 Now you open a new Form2 that contains a User Control How can you determine the Selected tab in Form1...
7
by: Terry Olsen | last post by:
How do I get this to work? It always returns False, even though I can see "This is True!" in the debug window. Do I have to invoke functions differently than subs? Private Delegate Function...
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: 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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.