3 ms·
Why did JS's with keyword not work out while similar constructs in Python and Ruby were fine?
by Onavo 2y ago
Why did JS's with keyword not work out while similar constructs in Python and Ruby were fine?
- chthonicdaemon 2y agoPython's `with` and Javascript's `with` don't do the same thing. In Python it introduces a context, which is a scope within which certain cleanup tasks are guaranteed, which improves the ergonomics of things that require you to close() at the end, similar to `defer` in Go. In Javascript it allows you to access object properties without prefixing with a name, which leads to confusion about scope.