Skip to content

About

Fake operator overloading used by a type Point

Resources

Stars

1 star

Watchers

1 watching

Forks

 
 

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Fake operator overloading for JavaScript

The type Point uses fake operator overloading and lets you do the following:

var Point = require("./point.js").Point;
var p = new Point();

p._ = new Point(1, 2) + new Point(3, 4) + new Point(5, 6);
console.log(p.toString()); // Point(9, 12)

Caveats:

  • The overloaded operators only work when used together with an assignment, in the above manner.
  • "" + mypoint won't invoke toString(), but valueOf(). Work-around: "" + mypoint._

About

Fake operator overloading used by a type Point

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages