Search Options
close
Search the following clips:
All Clips
Everyone's Clips
My Guides
Sign Up
Install
Learn More
Login
What Are "Anonymous Functions" In JScript?
prostoalex
follow
0
2-26-2008 5:44 PM
263 views
tags:
javascript
,
programming
,
development
,
webdev
Add a Comment
Login
to Comment. Not a member yet?
Sign up
Related Clips
Createblog
Firefox Update Patches Critical Security ...
Map of your name
Get Latitude and Longitude values from Goo...
Google to Launch Browser
Google's Chrome aims to Kill Windows
Chrome's inner workings--and an Easter egg
More clips from
prostoalex
The Complete Guide for You to Become an Al...
Git Magic
The Art of Engineering
Today's Top Clips
The rival to the Bible
Female Fighters: We Won't Stand for Male Dominance
Different nesting options :)
Layers of Red Cliffs on Mars (Photo)
Our "Digital Shadow" -a Mind-Bending Prediction
The Surge has Worked
Clive Thompson: Why Veteran Visionaries Will Save the World
Bush snubs Iran breakthrough opportunity
Scientists create solar cells with a twist.
Scientists Reach Hydrogen Storage Milestone
visit the
Top Clips page
View the Top Clips from
February 26, 2008
Embed This Clip In Your Site...
<div style="margin: 12px 0px; font-family: arial; color: #333333; background: #ffffff; border: solid 4px #e5e5e5; width: 100%; clear: left;"><div class="CM_CTB_Content_Wrap" style="margin: 0px; padding: 0px;background-color: #ffffff;"><div style="border-bottom: solid 1px #dcdcdc; white-space: nowrap; margin-bottom: 8px; background-color: #eeeeee ;background-image: url(http://clipmarks.com/images/source-bg.gif); background-repeat: repeat-x; height: 24px; line-height: 24px; vertical-align: middle; padding-bottom: 4px; color: #666666; font-size: 10px;" ><a href="http://clipmarks.com/clip-to-blog/" title="see clips that are hot right now"><img src="http://content.clipmarks.com/blog_embed/2d415819-3fca-40dc-aca8-b13f3543ab6b/F4C074DD-2E9B-45F4-8B07-6946EA1EA49D/" alt="" width="19" height="19" border="0" style="vertical-align: middle; margin: 0px 4px; display: inline; border: none; float:none;" /></a>clipped from <a title="http://blogs.msdn.com/ericlippert/archive/2003/09/16/53021.aspx" href="http://blogs.msdn.com/ericlippert/archive/2003/09/16/53021.aspx" style="font-size: 11px;">blogs.msdn.com</a></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://blogs.msdn.com/ericlippert/archive/2003/09/16/53021.aspx"><H4 class="BlogPostHeader">What Are "Anonymous Functions" In JScript? </H4></blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://blogs.msdn.com/ericlippert/archive/2003/09/16/53021.aspx"><SPAN>One of our excellent customer support staff in the <ST1:COUNTRY-REGION _moz-userdefined="" w:st="on"> <ST1:PLACE _moz-userdefined="" w:st="on">United Kingdom</ST1:PLACE> </ST1:COUNTRY-REGION> asked me this morning what "anonymous functions" are in JScript.<O:P _moz-userdefined=""></O:P> </SPAN></blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://blogs.msdn.com/ericlippert/archive/2003/09/16/53021.aspx"><SPAN>It's a little complicated. Two things come to mind: realio-trulio anonymous functions, and what we used to call "scriptlets".<O:P _moz-userdefined=""></O:P> </SPAN></blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://blogs.msdn.com/ericlippert/archive/2003/09/16/53021.aspx"><SPAN>First up are actual anonymous functions -- functions which do not have names are, unsurprisingly enough, called "anonymous functions".<O:P _moz-userdefined=""></O:P> </SPAN></blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://blogs.msdn.com/ericlippert/archive/2003/09/16/53021.aspx"><P class="MsoNormal"> <SPAN>"<B>What the heck do you mean, functions without names</B>?" I hear you ask.<SPAN> </SPAN>"<B>Surely all functions have names!"</B> -- well, no, actually, some don't.<SPAN> </SPAN>This is perfectly legal in JScript:<O:P _moz-userdefined=""></O:P> </SPAN> </P></blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://blogs.msdn.com/ericlippert/archive/2003/09/16/53021.aspx"><SPAN>print ( <SPAN>function(x){return x * 2;}</SPAN> (3) );<O:P _moz-userdefined=""></O:P> </SPAN></blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://blogs.msdn.com/ericlippert/archive/2003/09/16/53021.aspx"><SPAN>That prints out "6".<SPAN> </SPAN>What's the name of that function?<SPAN> </SPAN>It has no name.<SPAN> </SPAN>Of course, we could give it one if we chose.<SPAN> </SPAN>This is exactly the same as declaring a named function:<O:P _moz-userdefined=""></O:P> </SPAN></blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://blogs.msdn.com/ericlippert/archive/2003/09/16/53021.aspx"><P class="MsoNormal"> <SPAN>function double(x){return x * 2;}</SPAN><SPAN> <O:P _moz-userdefined=""></O:P> </SPAN> </P></blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://blogs.msdn.com/ericlippert/archive/2003/09/16/53021.aspx"><SPAN>print ( double(3) );<O:P _moz-userdefined=""></O:P> </SPAN></blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://blogs.msdn.com/ericlippert/archive/2003/09/16/53021.aspx"><SPAN>But functions don't need names any more than strings or numbers do.<SPAN> </SPAN>Functions are just functions whether they’re named or not.<O:P _moz-userdefined=""></O:P> </SPAN></blockquote></div><div style="margin: 0px 6px 6px 4px;"><table style="font-size: 11px;border-spacing: 0px;padding: 0px;" cellpadding="0" cellspacing="0" width="100%"><tr><td style="background:transparent;border-width:0px;padding:0px;"> </td><td align="right" style="background:transparent;border-width:0px;padding:0px;width:107px" width="107"><a href="http://clipmarks.com/share/F4C074DD-2E9B-45F4-8B07-6946EA1EA49D/blog/" title="blog or email this clip"><img src="http://content8.clipmarks.com/images/c2b-foot.png" border="0" alt="blog it" width="107" height="17" style="border-width:0px;padding:0px;margin:0px;" /></a></td></tr></table></div></div>
Clipmarks
Home
New Clips
Top Clips
Dashboard
Popular Topics
News
Life
Science
Technology
Entertainment
Get Started
Sign Up
Install Clipping Tool
How Clipping Works
Clip-to-Blog™
ClipSearch
Tools and Resources
FAQ
ClipWeek
Top Clippers
Top Tags
Site Map
About Clipmarks
About Us
Contact
Blog
Copyright
Privacy
EULA
OK