Skip to content

Instantly share code, notes, and snippets.

Last active Mar 8, 2018
What would you like to do?
A variable that increments itself whenever it's accessed.
class Increment{
constructor(value) {
this.current = +value || 0;
[Symbol.toPrimitive]() {
return ++this.current;
var increment = new Increment();
alert(increment + increment);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment