Given a type defined in javascript, for example:
var Point = (function () {
function Point(x, y) {
this.x = x;
this.y = y;
}
Point.prototype.dist = function () {
return Math.sqrt(this.x * this.y + this.x * this.y);
};
return Point;
})();
That can be used this way:
var p = new Point(10, 20);
console.log(p.dist());
Or so:
var p = new Point();
p.x = 10;
p.y = 20;
console.log(p.dist());
There is a direct way to convert an object that is normally returned by JSON, or declared using literal syntax in this way:
var p = { x: 10, y: 20 };
For my type Point
that has method dist()
without using from = to ?