user6920839 user6920839 - 1 month ago 6
Javascript Question

what is this.e in javascript

I am learning to make library like jquery and trying to understand a piece of code where this.e is giving me hard time, where this 'e' come from and they are assigning object to it but when they return this they return just this not this.e .

function _(a) {
var b = {
key: "some val"
};
if (a) {
if (window === this) {
return new _(a)
}
this.e = document.getElementById(a);
return this
} else {
return b
}
}
_.prototype = {
hide: function() {
this.e.style.display = "none";
return this
}


HTML

<button onclick="_('abc')">click</button>
<div id="abc" style="width: 200px; height: 100px; background-color: pink;"> </div>

Answer

It's just a convention to use e as function parameter name when the parameter is event. as in your example here the event is onclick