Hacker News new | ask | show | jobs
by dminik 302 days ago
That doesn't seem that obvious to me. You could have a setter that just calls exit and terminates the whole program.
1 comments

Yeah, this is actually a good point, could have a custom setter theoretically that simply looks like assignment, but does some fancy logic.

    const location = {
      set current(where) {
        if (where == "boom") {
            throw new Error("Uh oh"); // Control flow breaks here
        }
      }
    };

    location.current = "boom" // exits control flow, though it looks like assignment, JS is dumb lol