Element prototype as string

If it possible to create an Element.prototype as a string?

For example :

instead of :

Element.prototype.height = function() { return this.offsetHeight; };

to write something like this :

Element.prototype.height = Element.offsetHeight;

Answers


You could try something like this:

Element.prototype = {
        get height( ):{   return this.offsetHeight;   }
        constructor : Element
};

Usage:

new Element().height    //without parenthesis

More about, see Object getters/setters.


Need Your Help

Display names of markers within cluster onmouseover

leaflet markerclusterer

I'm trying to display a map with clustered markers, where the user can see the names of the markers within the cluster on mouseover, before clicking to zoom in.

SoapExtension not loading

c# asp.net web-config soap-extension

I'm trying to write a soap extension. But the framework is not loading it.