in

ASP.NET Weblogs

Andy Smith's Blog

Page.RegisterStartupScript('Andy', 'MetaBuilders_WebControls_GainKnowledge();');

documentation of previous javascript syntax discovery

After hunting a bit in the official standard for ecmascript ( javascript ), I found where it defines the behavior darren found, and that I really liked.

It is listed in section 11.1.5 as “Object Initialiser”.

An object initialiser is an expression describing the initialisation of an Object, written in a form resembling a literal. It is a list of zero or more pairs of property names and associated values, enclosed in curly braces. The values need not be literals; they are evaluated each time the object initialiser is evaluated.

Being able to

define, instantiate, and initialize an object, declaratively, in one statement-section of code... it's amazingly useful.

I just don't get how... after my YEARS of using javascript... that I've never come across this syntax.

Comments

 

chadb said:

Interesting - kind of like old VB syntax. I've never seen it used -- is there some performance penalty? I would imagine so with all the parsing...
September 22, 2003 3:29 PM
 

Andy Smith said:

javascript is already parsed. there shouldn't be any difference in execution times... it's simply a different way to say it.
I seem to remember darren saying there is no perf difference.
September 22, 2003 4:52 PM

Leave a Comment

(required)  
(optional)
(required)  
Add