|
Spec-Zone .ru
спецификации, руководства, описания, API
|
Two operators over data type.
Table 6.4. Binary Logical Operators
| Operator | Meaning | Operand Types | Result Type |
|---|---|---|---|
| instanceof | Is this object of the specified type | Object instanceof Type | Boolean |
| as | Convert this object to the specified type | Object as Type | Object (of type Type) |
For example:
function toString(val : Object) : String {
if (val instanceof String)
val as String
else
"Not a String"
}
This example function uses instanceof to check if the input is a String, and if it is, it changes the type of the expression to String using the as operator.