Skip to content

Call javascript constructors with arguments

Hannes Hirzel edited this page Apr 28, 2014 · 4 revisions

Amber has the following methods which can be used to call JS constructors that take arguments:

  • BlockClosure>>#newValue:
  • BlockClosure>>#newValue:value:
  • BlockClosure>>#newValue:value:value:

Examples:

new Foo();                // JS version 
Foo new.                  "Amber version" 

new Foo(1,2);             // JS version 
Foo newValue: 1 value: 2. "Amber version" 

This recipe was posted to the Amber mailinglist by Andy Bower.

Literal notation may be used for arguments.

More on Smalltalk and JavaScript

Clone this wiki locally