> -----Original Message----- > From: Dominic Watson [mailto:[EMAIL PROTECTED] > Sent: Monday, March 17, 2008 8:38 PM > To: CF-Talk > Subject: Re: UDF function inside cffunction? > > > > > While that's not a nested function (again, you're just assigning a > > function > > as data), you can definitely build them in JavaScript: > > > You learn something new every day ;). Thats interesting that functions > that > are 'scoped' to variables are treated as 'data' and not referred to in > object terms, any idea why that is? You certainly use them in exactly > the > same way as methods in an object. Can they be scoped publicly / > privately? > Sorry for drifting off topic, but its interesting stuff init :p
It's really just semantics... you can call them methods and everybody will understand what you mean. ;^) But - technically - in JavaScript there really isn't a "thing" called a method, just a very flexible function object. It's sometimes useful to think about things as they really are - it opens up a lot of potentials. For example, since functions are objects you can assign properties to them: function MyFunction() { }; MyFunction.MyProperty = 42; Of course since functions are data that could be a function as well: function MyFunction() { }; MyFunction.MyProperty = function() { }; Here's a brief, but great overview of nearly everything you can do with functions in JS: http://www.permadi.com/tutorial/jsFunc/index.html Basically when you start "getting" how flexible objects are in JavaScript and then add that functions are objects a lot of new approaches open themselves up. Another thing that many people seem to forget is that (for the most part) "system" objects are also, well - objects. They can have additional properties added (and since functions are data they can have "methods" added...). A simple example: Say you have several form buttons on the page. You want to change a graphic when each is pressed, but you also want to count the number of times each is pressed. Most people create an array of "presscounts" with an index for each button... but this data is related to the button? Doesn't it make more sense to add a property to the button to count the presses? Using advanced event management (available in most libraries) you can set up multiple "onclick" handlers - one would just increase the "presscount". You can then access the presscount as a property of the button: document.getElementById("MyButton").presscount This may be a silly example but there are cases where it comes in handy... radio buttons can pass around large amounts of complex data by extending them (rather than just know "clicked" or "not clicked"), text controls can maintain history allowing complex application to offer "undo" capability and so forth. As much as I love the accessibility and power of CF and as much as I'm stuck doing grunt work with Shell Scripting JavaScript has always been, by far, the most exciting language to me. You can really never "learn" it completely since the flexibility it provides will always surface something new to try. Jim Davis ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;160198600;22374440;w Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:301503 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4