Are Unity's JS OOP functions customized?


I’m learning implementation of OOP in JS, and seem to be getting conflicting answers from Javascript textbooks and Unity JS tuts.

Case in point:

    function smpl_generic (a: float, b: float, c: float)
	this.a = a;
	this.b = b;
	this.c = c;

…barfs with ‘a’ not being a member of smpl_generic (filename). Google book link in context.

This, from a WalkerBoy tutorial seems to work, however:

class Test
 var a;
 function Test(aA: float)
    a = aA;

To compound my confusion, from what I’ve been reading is that JS creates classes by itself without announcing them, and that I need to create prototypes for methods. This is NOT from what I’ve seen being written.

In the link I provided (it’s just a single block of text), can someone explain to me what exactly differs in Unity’s implementation of JS?

So I’m afraid the first thing to learn is that Unity Script (JavaScript) is not at all like ECMAScript (JavaScript) they share some of the same syntax but Unity Script is a .NET based language built on top of Boo. If you want to learn JavaScript go write some HTML5 for a browser - if you want to learn Unity Script, be aware that there are significant differences to JavaScript and your JavaScript reference books are not going to help much. Buy a Unity programming book or program in C# (which is the same as C# everywhere).

You’d be better off learning ActionScript 3 if you want to learn Unityscript. It’s a lot more similar. Just ignore Javascript, it doesn’t really have anything to do with Unity.