If I have the following function:
function foo(){
alert('hi');
}
and I don't need to pass any parameters to it, is calling it this way:
foo;
the same as calling it this way:
foo(); 8 2949
Yansky <th*********@gm ail.comwrites:
If I have the following function:
function foo(){
alert('hi');
}
and I don't need to pass any parameters to it, is calling it this way:
foo;
the same as calling it this way:
foo();
No. foo; does not call it at all. It's a statement returning the
function foo, but since you're not doing anything with the value it's
a useless statement.
A contrived example of foo; is:
var bar = foo; // assign function foo to bar
bar(); // call the function.
IOW, you do need the parentheses if you want to call a function.
--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
On Jul 18, 8:12*am, Joost Diepenmaat <jo...@zeekat.n lwrote:
Yansky <thegoodd...@gm ail.comwrites:
If I have the following function:
function foo(){
* alert('hi');
}
and I don't need to pass any parameters to it, is calling it this way:
foo;
the same as calling it this way:
foo();
No. foo; does not call it at all. It's a statement returning the
function foo, but since you're not doing anything with the value it's
a useless statement.
A contrived example of foo; is:
var bar = foo; // assign function foo to bar
bar(); *// call the function.
IOW, you do need the parentheses if you want to call a function.
--
Joost Diepenmaat | blog:http://joost.zeekat.nl/| work:http://zeekat.nl/
Thanks for clearing that up. :)
On Jul 18, 8:40*am, Yansky <thegoodd...@gm ail.comwrote:
On Jul 18, 8:12*am, Joost Diepenmaat <jo...@zeekat.n lwrote:
Yansky <thegoodd...@gm ail.comwrites:
If I have the following function:
function foo(){
* alert('hi');
}
and I don't need to pass any parameters to it, is calling it this way:
foo;
the same as calling it this way:
foo();
No. foo; does not call it at all. It's a statement returning the
function foo, but since you're not doing anything with the value it's
a useless statement.
A contrived example of foo; is:
var bar = foo; // assign function foo to bar
bar(); *// call the function.
IOW, you do need the parentheses if you want to call a function.
--
Joost Diepenmaat | blog:http://joost.zeekat.nl/|work:http://zeekat.nl/
Thanks for clearing that up. :)
Oh wait I have one more question. What about when you're calling the
function inside an event listener? e.g.
function foo(){
alert('hi');
}
window.addEvent Listener("load" , foo, false);
Yansky wrote:
On Jul 18, 8:12 am, Joost Diepenmaat <jo...@zeekat.n lwrote:
>Yansky <thegoodd...@gm ail.comwrites:
>>If I have the following function: function foo(){ alert('hi'); } and I don't need to pass any parameters to it, is calling it this way: foo; the same as calling it this way: foo();
That's probably the second most stupid question I have ever read on Usenet.
>No. foo; does not call it at all. It's a statement returning the function foo, but since you're not doing anything with the value it's a useless statement.
A contrived example of foo; is:
var bar = foo; // assign function foo to bar bar(); // call the function.
IOW, you do need the parentheses if you want to call a function. [...]
Thanks for clearing that up. :)
I really wonder what is so difficult about trying something out before
asking (or to read the available reference material, including this
newsgroup's FAQ, for that matter). If you are this afraid that code that
you write could have effects this dangerous on the computer you are
developing on, you should forget all about programming and computer science,
and move to a happy little island nowhere near any technology.
<http://jibbering.com/faq/>
<http://catb.org/~esr/faqs/smart-questions.html>
PointedEars, shaking his head
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
Yansky wrote:
Oh wait I have one more question.
You don't say.
What about when you're calling the function inside an event listener?
e.g.
function foo(){
alert('hi');
}
window.addEvent Listener("load" , foo, false);
`foo' refers to the (event) listener, which is the user-defined function.
Again, the function is _not_ called here, but being referred to. It is
called *later*, by the DOM implementation' s event handler, using the passed
Function object reference.
RTFM. RTFFAQ. STFW.
PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f8************ *******@news.de mon.co.uk>
On Jul 18, 8:50*am, Thomas 'PointedEars' Lahn <PointedE...@we b.de>
wrote:
Yansky wrote:
On Jul 18, 8:12 am, Joost Diepenmaat <jo...@zeekat.n lwrote:
Yansky <thegoodd...@gm ail.comwrites: If I have the following function: function foo(){ * alert('hi'); } and I don't need to pass any parameters to it, is calling it this way: foo; the same as calling it this way: foo();
That's probably the second most stupid question I have ever read on Usenet.
w00t!
Yansky wrote:
Thomas 'PointedEars' Lahn wrote:
>Yansky wrote:
>>On Jul 18, 8:12 am, Joost Diepenmaat <jo...@zeekat.n lwrote: Yansky <thegoodd...@gm ail.comwrites: If I have the following function: function foo(){ alert('hi'); } and I don't need to pass any parameters to it, is calling it this way: foo; the same as calling it this way: foo();
That's probably the second most stupid question I have ever read on Usenet.
w00t!
And that's definitely the most stupid reply I have ever read.
Congratulations . Don't you want to apply for the Darwin Award as well?
PointedEars
--
var bugRiddenCrashP ronePieceOfJunk = (
navigator.userA gent.indexOf('M SIE 5') != -1
&& navigator.userA gent.indexOf('M ac') != -1
) // Plone, register_functi on.js:16
Yansky wrote:
Oh wait I have one more question. What about when you're calling the
function inside an event listener? e.g.
function foo(){
alert('hi');
}
window.addEvent Listener("load" , foo, false);
That's fine, you're not calling it, you're nominating it as the function
that should be called.
Here, alias will be set to 3;
function foo(){return 3;};
var alias=foo();
Here, alias will become an actual alias of the function foo.
function foo(){return 3;}
var alias=foo;
//you can now do this:
alert(alias()); //alert 3 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Muthu |
last post by:
I've read calling conventions to be the order(reverse or forward) in
which the parameters are being read & understood by compilers.
For ex. the following function.
int Add(int p1, int p2, int p3);
The parameters here can be read either in the forward order from p1
till p3 or reverse order from p3 till p1.
Can anyone explain what is the advantage/disadvantage of either of
|
by: Zlatko Matiæ |
last post by:
Hello.
How can I call some functions on MSDE when working in .mdb ? Especially
in-line functions which are similar to stored procedures.
How can I use MSDE in-line functions as recordsource for .mdb forms ?
Can I call in-line functions using ADO ? I tried, but it seems that only
stored procedures are allowed (adCmdStoredProc)....
Thanks.
|
by: Tim Marshall |
last post by:
Here's the scenario, A2003, Jet back end, illustrated with some cut down
code at the end of the post:
A proc dims a snapshot recordset (dim rst as Dao.recordset) and opens
it. There are several nested do loops, going through the records in rst
using .movenext. At one point in one of the loops, we'll say the rst is
at record "a". Now, another subprocedure is called, passing rst to it.
In the subprocedure, the recordset goes through a...
|
by: pkpatil |
last post by:
Hi,
I recently saw a code with a mix of C & C++, wherein a C++ file was
calling a C function dropping the last argument. The code was similar
to below:
--------------------------------------------------------------------------------------------------------------
cfile.c
---------
C_Fun(int arg1, int arg2, int arg3) { // C function with three
parameters
|
by: Geler |
last post by:
A theoretical question: Sorry if its a beginner question.
Here is a quote from the MSDN explaning the C/C++ calling convention.. It
demonstrates that the calling function is responsible to clean the stack
pointer and it does it by the command "add esp,8" after returning from
the called function.
My questions:
1. Is the stack pointer common in a certain thread(or process)?
2. How does the called function get the parameters, is it by...
| |
by: John Friedland |
last post by:
My problem: I need to call (from C code) an arbitrary C library
function, but I don't know until runtime what the function name is,
how many parameters are required, and what the parameters are. I can
use dlopen/whatever to convert the function name into a pointer to
that function, but actually calling it, with the right number of
parameters, isn't easy.
As far as I can see, there are only two solutions:
1) This one is portable. If...
|
by: rocketfire97 |
last post by:
I'm trying to call a COM object using C# but having no luck getting
values back for passed in ref objects.
I've tried the same call using VB.NET and can get data back. How would
I implement the following in C#
This is the method I am calling, which populates ref paramters with
results.
Sub Check_Customer(ByVal Customer As String, Optional ByRef oParam1 As
|
by: sulekhasweety |
last post by:
Hi,
the following is the definition for calling convention ,which I have
seen in a text book, can anyone give a more detailed explanation in
terms of ANSI - C
"the requirements that a programming system places on how a procedure
is called and how data is passed between a calling program and
procedures are called calling conventions"
|
by: Ole Nielsby |
last post by:
VC has a __cdecl specifier which allows functions and methods to
be called with varying parameter count.
(I understand this is the default for functions in general but in VC,
instances use another convention unless they have an ellipsis
argument.)
I can force GCC and other compilers to use such a convention by
declaring all methods with an ellipsis, but I'd rather not clutter my
method definitions with these.
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |