Just wondering what’s the meaning of “:” (colon symbol) on this Javascript code below?
var switchToTarget : Transform;
Thanks,
Gino
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Edit: Reading more about Unity, they have created a really custom implementation of JavaScript(1) for their scripting engine, which is compiled and it has a lot of strongly typing features, it looks like ActionScript/ES4, but it isn’t, the language is called UnityScript.
The colon is used by this implementation to denote the type of an identifier, e.g.:
See also:
The code you posted is not valid ECMAScript 3, (which is the most widely implemented standard), that will simply give you a
SyntaxError.The colon symbol in JavaScript has only a few usages:
The object literal syntax:
The conditional operator:
Labeled statements:
Case and default clauses of the switch statement:
It can appear on RegExp literals: