Hi, I just started using Unity Javascript and wondered if there is any difference between using new for object creation and not using it. For instance, is there any difference between a & b below? Both seem to work fine.
var a: Action = Action(2, 2);
var b: Action = new Action(2, 2);
The New keyword
In Javascript, you can create a new instance of an object or struct without using the ‘new’ keyword. In C#, using “new” is mandatory.
// Javascript:
var myPosition = Vector3(0,0,0);
var myInstance = MyClass(); // creates a new instance of script "MyClass".
var myTex = Texture2D(128,128); // creates a new texture2d object.
// C#
Vector3 myPosition = new Vector3(0,0,0);
MyClass myInstance = new MyClass();
Texture2D myTex = new Texture2D(128,128);
from : http://answers.unity3d.com/questions/12911/what-are-the-syntax-differences-in-c-and-javascrip.html