return
statement JS-0030 1748 return true;
1749 }
1750 get reloadReason() {
1751 return; 1752 }
1753 prepareToRender() {
1754 return;
640 }
641 addEventListener("click", clickCaptured, true);
642 Object.defineProperty(prototype, "submitter", {
643 get() { 644 if (this.type == "submit" && this.target instanceof HTMLFormElement) {
645 return submittersByForm.get(this.target);
646 }
3041 get shouldRender() {
3042 return this.newSnapshot.isVisitable && this.trackedElementsAreIdentical;
3043 }
3044 get reloadReason() { 3045 if (!this.newSnapshot.isVisitable) {
3046 return {
3047 reason: "turbo_visit_control_is_reload"
4024 get enabled() {
4025 return !this.element.disabled;
4026 }
4027 get sourceURL() { 4028 if (this.element.src) {
4029 return this.element.src;
4030 }
4137 const newChildrenIds = [...((_a = this.templateContent) === null || _a === void 0 ? void 0 : _a.children) || []].filter((c) => !!c.id).map((c) => c.id);
4138 return existingChildren.filter((c) => newChildrenIds.includes(c.id));
4139 }
4140 get performAction() { 4141 if (this.action) {
4142 const actionFunction = StreamActions[this.action];
4143 if (actionFunction) {
The get
syntax binds an object property to a function that will be called when that property is looked up.
So, there should always be a return
statement in property getters.
For example :
const person = {
firstName: 'John',
lastName: 'Doe',
get fullName() {
return `${this.firstName} ${this.lastName}`;
}
}
console.log(person.fullName); // => John Doe
// When the fullname property gets looked up
// the getter function gets executed and its
// returned value will be the value of fullname
Every getter
function is expected to return a value.
const p = {
get name(){
// no returns.
}
};
Object.defineProperty(p, "age", {
get: function (){
// no returns.
}
});
class P {
get name(){
// no returns.
}
}
const p = {
get name(){
return "nicholas";
}
};
Object.defineProperty(p, "age", {
get: function (){
return 18;
}
});
class P{
get name(){
return "nicholas";
}
}