I’ve seen a few JavaScript code examples that use this sort of syntax:
function(foo:String) {
// code
}
I assume it does some sort of typecasting, but haven’t been able to find much information about this syntax. Does anyone know what this is called, and where it is documented? Is this strict JavaScript or a browser extension?
As far as I know, that’s not valid JavaScript. Rather, it’s ActionScript (with both languages being based on the ECMAScript standard). It simply tells the compiler that the parameter’s type is
Stringor any of its subclasses.This declaration is covered in Adobe’s AS3 documentation for variables. The same syntax is used for local variables, fields, function parameters and function return types.