4 ms·
It'd be nice to be able to blur the lines. Maybe implement multireturn by declaring variables public inside your closure scope. function Person(firstName, la
by jtolmar 6y ago
It'd be nice to be able to blur the lines. Maybe implement multireturn by declaring variables public inside your closure scope.
function Person(firstName, lastName) {
let fName = firstName;
let lName = lastName;
public getFullName = function() {
return fName + ' ' + lName;
};
public setFirstName = function(firstName) {
fName = firstName;
};
return this;
}
("return this" is probably not the best syntax at the end there, especially if bolting this onto javascript.)
- LudwigNagasena 6y agoI remember trying to think about something similar when I wanted to invent a language that tries to stay as close to “everything is an X” as possible. (But it was a mess, unfortunately) I would use “return scope”.
- jtolmar 6y ago"scope" was actually on my short list of possibilities :-)
- szatkus 6y agoThat's just Python classes.