Wednesday, 15 August 2012

ecmascript 5 - How can "new new Something" produce valid results in JavaScript? -



ecmascript 5 - How can "new new Something" produce valid results in JavaScript? -

i'm developing javascript parser , study ecmascript 5.1 specification. here's question puzzles me @ moment.

§ 11.2 left-hand-side expressions defines next newexpression production:

newexpression : memberexpression new newexpression

if read correctly, newexpression may like

new new

(actually, any amount of news.)

this puzzles me completely. how new something potentialy homecoming 1 time 1 time again new? possible @ all?

it not mutual @ all, possible; function returns function:

function baz(){} function foo(){return baz} new new foo() instanceof baz // true

javascript ecmascript-5

No comments:

Post a Comment