Example:
function action(value) {
// I want to operate on a string
String(value)...;
}
When we pass dynamic values into JavaScript's primary types (String
, Number
, Boolean
, Object
, etc.) we can (for want of a better word) cast the value to the specified type.
Is it possible to build this feature in custom types, and how would I go about this?
Example of what I would like to do:
function action(value) {
Point(value)...;
// Value at this point (excuse the pun) is a point
// // *** Would like to see that intellisense is aware of the type at this point, but please don't assume this is ONLY for intellisense***
}
Is it possible to call constructor functions in this way and have the constructor function cast the value to an instance of itself - or does this only work for JavaScript's primary types?