Maybe some little kind of protection would be helpful.
One of minimal solution I see is to have a well-known object that holds
all of the descriptor defaults (Reflect.defaultPropertyDescriptor), and:
- when returning descriptor from API, make it `__proto__:R.dPP`
- when creating descriptor,
Le 29/11/2012 06:20, Brandon Benvie a écrit :
The answer though in that case is easy enough though, make sure the
prototype descriptor is created with Object.create(null). This
wouldn't solve compatibility issues with in-the-wild code but it
solves the issue for most people who care enough to
Object.defineProperty(obj,key, Object.create(defaultDataProperty, {value:
123});
Er, shouldn't that be:
Object.defineProperty(obj,key,Object.create(null, {value: {value: 123}}));
Seems pretty excessive. It's probably too late to make defineProperty only look
at own properties, but how about
Le 29/11/2012 16:47, Nathan Wall a écrit :
In addition, it'd be nice if there was an easier way to create an
object with no [[Prototype]]... some sort of addition to object
literal notation?
I think ES6 will have such a notation with the __proto__ de facto
standardization:
var o = {
On Nov 29, 2012, at 7:47 AM, Nathan Wall wrote:
Object.defineProperty(obj,key, Object.create(defaultDataProperty, {value:
123});
Er, shouldn't that be:
Object.defineProperty(obj,key,Object.create(null, {value: {value: 123}}));
oops, yes create requires an addition object layer
Le 29/11/2012 17:02, Allen Wirfs-Brock a écrit :
On Nov 29, 2012, at 7:47 AM, Nathan Wall wrote:
Seems pretty excessive. It's probably too late to make defineProperty
only look at own properties, but how about making it ignore
properties inherited from Object.prototype?
Fairly complex to
I really don't understand what is exactly the advantage of considering
inherited properties for descriptors.
If you create a new instance with those properties using a class to avoid
writing them ... what are you gaining against a literal object?
If you are doing this in order to have less code
Andrea Giammarchi wrote:
I really don't understand what is exactly the advantage of considering
inherited properties for descriptors.
It's easy to overreact here. Don't mess with Object.prototype still
applies, or you will have other WTF moments.
ES5 shipped this and browsers shipped
I will ... but I still would like to know why other developers are using
inheritance for this.
No memory, performance, size, benefits and more verbose code, i.e.
Object.defineProperty(o, p, Object.create(null, {value:{value:v}}))
OR
Object.defineProperty(o, p, new DefaultDescriptor(v));
VS
Here's a place I've made use of it, note Descriptor and Descriptors.
https://github.com/Benvie/benvie.github.com/blob/master/client/modules/site/introspect.js#L221
___
es-discuss mailing list
es-discuss@mozilla.org
that's actually cool, but you suffer same problem? :-)
desc.enumerable = 'get' in desc;
On Thu, Nov 29, 2012 at 1:07 PM, Brandon Benvie
bran...@brandonbenvie.comwrote:
Here's a place I've made use of it, note Descriptor and Descriptors.
Updated MDN:
https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/defineProperty#Description
Hope it's fine, feel fere to edit/add/change that, thanks
On Thu, Nov 29, 2012 at 12:23 PM, Andrea Giammarchi
andrea.giammar...@gmail.com wrote:
I will ... but I still
On Nov 28, 2012, at 6:40 PM, Andrea Giammarchi wrote:
This was not true at some point, but now it seems to be the case in every
browser.
Just
Object.prototype.get = function(){};
and any further attempt to use Object.defineProperty(obj, key, {value:123})
will fail because
To answer that question, I do. I reuse descriptors often for performance
but also use prototypal inheritance as well.Since most descriptors share
the same common properties for all but one (or two) fields, they are an
ideal candidate for use with prototypal inheritance.
The answer though in that
14 matches
Mail list logo