- Home /
Some JavaScript questions
Since I never had close contact with javascript I would like to clarify some aspects:
Whenever I'm assigning new instance of an object to a variable does the previous object is deleted as it happens in java (with help of garbage collector)?
Can I declare a class as abstract one and there are interfaces in javascript? If the answer is yes then give me a little example, please. Just to see its syntax..
If you want good documentation, and interfaces and abstract classes, you should use C# ins$$anonymous$$d of javascript. Co$$anonymous$$g from a java background, C# will be more familiar to you, and there is much more documentation and knowledge out there about C# than there is about UnityScript. The Javascript implementation that is used in Unity is unique, so the only places where there is any information about it are Unity-specific.
Answer by BetaWar · Feb 29, 2012 at 09:12 PM
I am not 100% sure here, I haven't really dived into the UnityScript engine as of yet, but in Javascript and Actionscript 3 (both of which are based off of the ECMA Script standard), objects which have no references to them (orphaned variabled) are removed (or queued for removal) by the garbage collector; so I assume that it is the same here with UnityScript.
As syclamoth stated, UnityScript is a unique version of Javascript (though it is closest to using the ECMA Script 4 standard -- the same on that Actionscript 3.0 uses). You can create interfaces though, and it is pretty much exactly the same as in Java. Here is a quick interface example for UnityScript:
public interface MyInterface{
function GetMyName():String;
}
To implement the interface you also do it like in Java:
class MyClass inplements MyInterface{
public function GetMyName():String{
return "BetaWar";
}
}
Hopefully that helps.
Your answer
Follow this Question
Related Questions
Dictionary.TryGetValue for js 1 Answer
UnityScript - Class reference 1 Answer
Reference JS string to C# 1 Answer
How do I reference variables from other class files? 1 Answer