Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> JavaScript is forced to make the pessimal choice of only ever having dynamic-bound "this", because of that favorite whipping boy ... prototypal inheritance.

I don't think that's true: functions accessed via objects could very well be bound to the object (that's what Python does, accessing a method via an object instance returns a "bound method" which is curried with the instance, whereas accessing the same method via the class returns an "unbound method" which requires a class instance as its first argument).



That works in Python, because Python has a distinction between an "instance" object, and, say, a Dict. In JavaScript an object is an object is an object -- under your proposed change, what would be the value of "this, in this:

    Klass.prototype.method = options.method;


> That works in Python, because Python has a distinction between an "instance" object, and, say, a Dict.

Not really, it's trivial to create a dict-like object which allows access to keys as properties, just override `__getattr__`.

> In JavaScript an object is an object is an object

No, objects can have a non-null [[prototype]] indicating it was created from using `new` on a constructor.

> Klass.prototype.method = options.method;

Depends what `options` is.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: