require("./as.js");
class Point {
constructor(x, y) {
this.x = x;
this.y = y;
}
length() {
return Math.sqrt(this.x * this.x + this.y * this.y);
}
}
let length = ({x: 4, y: 3}).as(Point).length();
console.log(length); // 5
-
Notifications
You must be signed in to change notification settings - Fork 0
ichko/as.js
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
JS cast anonymous object
Topics
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published