3 ms·
It’s actually easier in JavaScript compared to either language…. var foo = {} foo.bar = “hello new property” console.log(foo.bar)
by taf2 3y ago
It’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)")