I need to write a few extension methods in JS. I know just how to do this in C#. Example:
public static string SayHi(this Object name)
{
return \"Hi \"
Using Global augmentation
declare global {
interface DOMRect {
contains(x:number,y:number): boolean;
}
}
/* Adds contain method to class DOMRect */
DOMRect.prototype.contains = function (x:number, y:number) {
if (x >= this.left && x <= this.right &&
y >= this.top && y <= this.bottom) {
return true
}
return false
};