api mapping

memolus at googlemail.com memolus at googlemail.com
Sun Dec 27 03:32:00 PST 2009


David-Sarah Hopwood wrote at 25th December:
> and there is no need for a 'link' convenience function to be standardized
> given that it is a 5-liner in terms of Object.defineProperty

Just have a look at the following programming code with *sweet* 5-liners:

var Gui = function()
{
	this.init.apply(this, arguments);
}

Gui.prototype = new function()
{
	this.init = function()
	{
		let title = document.getElementById("title");
		Object.defineProperty(this, "title",
			{get: function() { return title.value; },
			set: function(x) { title.value = x; },
			enumerable: true
		 	});

		let url = document.getElementById("url");
		Object.defineProperty(this, "url",
			{get: function() { return url.value; },
			set: function(x) { url.value = x; },
			enumerable: true
			});

		let input = document.getElementById("input");
		Object.defineProperty(this, "url",
			{get: function() { return input.value; },
			set: function(x) { input.value = x; },
			enumerable: true
			});
	}
}


More information about the es-discuss mailing list