mzeeshan – 18-54 Dec 25

hello there... Question..... what is the meaning of line 4 , i mean why there is , e .......?
document.body.appendChild(
(function () {
const e = document.createElement("div");
line 4 => return (e.innerHTML = ["Hello", "webpack"].join(" ")), e;
})()
);
document.body.appendChild(
(function () {
const e = document.createElement("div");
line 4 => return (e.innerHTML = ["Hello", "webpack"].join(" ")), e;
})()
);
S
ScriptyChris480d ago
Line 4 uses comma to execute stuff and then return last expression, which is e - so the div https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comma_Operator @mzeeshan It's more readable in this form:
const e = document.createElement("div");
e.innerHTML = ["Hello", "webpack"].join(" ");
return e;
const e = document.createElement("div");
e.innerHTML = ["Hello", "webpack"].join(" ");
return e;
F
front-end480d ago
thanks a lot
UU
Unknown User479d ago