Re:JavaScript Structs
by Onavo on Friday October 11, 2024 @11:41AM
(#41810462)
Why did JS's with keyword not work out while similar constructs in Python and Ruby were fine?
[ Parent
| on HN ]
Re:JavaScript Structs
by chthonicdaemon on Friday October 11, 2024 @11:46AM
(#41810513)
Python'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.