strawman for the := operator

Axel Rauschmayer axel at
Wed Aug 8 18:57:24 PDT 2012

>> The problem is that neither = nor Object.defineProperty can be used succinctly and reliably to shadow or override.
> OK, that's the real problem, thanks for making it clear -- sorry if I missed it before.

I still find the difference between assigning and defining very subtle. I am still trying to fully wrap my head around it.

Isn’t there a reverse danger, too? That people use define when they actually want to use assignment? They might, for example, use := and expect a setter to be called.

What is the use case for overriding? Isn’t it usually when you copy one object to another (a.k.a. Object.update() or Object.assign())? There you see code such as:

  // Extend a given object with all the properties in passed-in object(s).
  _.extend = function(obj) {
    each(, 1), function(source) {
      for (var prop in source) {
        obj[prop] = source[prop];
    return obj;

Clearly, here it is wrong to use assignment, but one has not choice if one wants to be compatible with ES3.

Isn’t the answer Object.update(), then? Or are there other common pitfalls?

Dr. Axel Rauschmayer
axel at


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list