3 ms·
This kind of thing is possible in both python and javascript, it's just generally discouraged.
by rcxdude 3y ago
This kind of thing is possible in both python and javascript, it's just generally discouraged.
- taf2 3y agoIt’s actually easier in JavaScript compared to either language…. var foo = {} foo.bar = “hello new property” console.log(foo.bar)
- rubyn00bie 3y agoYour example is not equivalent to the Ruby code. You’re just assigning a value to a property which is always exposed, you’re showing getters/setters. The instance variables are not by default exposed or accessible outside the class/object.
- danielheath 3y agoOn the other hand... foo = {bar: "123"}; with (foo) eval("console.log(bar)")