SitePoint Sponsor |
|
User Tag List
Results 1 to 9 of 9
Thread: Pass function name in arguments
-
Apr 27, 2007, 17:42 #1
- Join Date
- Dec 2002
- Location
- Canada
- Posts
- 2,476
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Pass function name in arguments
Say I wanted to call a function like so
doSomething('test', "aFunction");
how could I have the doSomething function later called aFunction, or whatever was passed?AskItOnline.com - Need answers? Ask it online.
Create powerful online surveys with ease in minutes!
Sign up for your FREE account today!
Follow us on Twitter
-
Apr 27, 2007, 18:35 #2
- Join Date
- Sep 2006
- Posts
- 731
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
-
Apr 27, 2007, 18:56 #3
- Join Date
- Dec 2002
- Location
- Canada
- Posts
- 2,476
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
AskItOnline.com - Need answers? Ask it online.
Create powerful online surveys with ease in minutes!
Sign up for your FREE account today!
Follow us on Twitter
-
Apr 27, 2007, 21:42 #4
- Join Date
- Mar 2005
- Location
- USA
- Posts
- 5,482
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I'm not aware of a term for it. It's just one of the basics of how variables and functions work in JavaScript. So, yes, it's supported by all browsers that support JavaScript.
All variables and functions are properties and methods, respectively, of some object. Global variables and functions are properties and methods, respectively, of the global object, which is known as "window", among other things. Thusly you can access (get references for) global variables and functions via window.variableName (using dot syntax) or window['variableName'] (using array syntax).Last edited by Kravvitz; Apr 27, 2007 at 22:13.
We miss you, Dan Schulz.
Learn CSS. | X/HTML Validator | CSS validator
Dynamic Site Solutions
Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.
-
Apr 27, 2007, 22:09 #5
- Join Date
- Dec 2002
- Location
- Canada
- Posts
- 2,476
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
AskItOnline.com - Need answers? Ask it online.
Create powerful online surveys with ease in minutes!
Sign up for your FREE account today!
Follow us on Twitter
-
Apr 27, 2007, 22:16 #6
- Join Date
- Mar 2005
- Location
- USA
- Posts
- 5,482
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I added one dot by mistake. I edited my post to fix it.
They should look like this:
Code:window.variableName window['variableName']
We miss you, Dan Schulz.
Learn CSS. | X/HTML Validator | CSS validator
Dynamic Site Solutions
Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.
-
Apr 28, 2007, 01:00 #7
- Join Date
- Apr 2004
- Location
- germany
- Posts
- 4,324
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
-
Apr 28, 2007, 04:08 #8
- Join Date
- Apr 2007
- Posts
- 813
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
function in javascript is an object reference itself. This reading will literally help your understanding. More practises are needed if you are not well experienced with javascript
-
Apr 28, 2007, 04:31 #9
- Join Date
- Apr 2004
- Location
- germany
- Posts
- 4,324
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
javascript is a pure OO language, that is, everything is an object reference, not only function.
Bookmarks