Skip to content

Instantly share code, notes, and snippets.

@shapkarin
Last active November 14, 2018 10:33
Show Gist options
  • Save shapkarin/c19bec88d4a2d8ad2e28 to your computer and use it in GitHub Desktop.
Save shapkarin/c19bec88d4a2d8ad2e28 to your computer and use it in GitHub Desktop.
var Increment = function() {
this.int = 0;
};
Increment.prototype.toString = function() {
return ++this.int;
};
var increment = new Increment();
alert(increment);
alert(increment);
alert(increment + increment);

Создайте конструктор, экземпляры которого будут возвращать инкрементированное число

var increment = new Increment();  
alert(increment); /* 1 */  
alert(increment); /* 2 */  
alert(increment + increment); /* 7 */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment