I'm pretty sure you can't do this in ES3 with only standard support, and here's why: Look at x and y creation var fn = function(){}; fn. Prototype = {}; var x = new fn, y = new Object When x is instantiated, its internal Prototype is being set to an object referenced by fn. Prototype (just an Object object that you assigned to fn.
Prototype ). Object's constructor fn is then being called in a context of that newly created object, but since it doesn't mutate ab object in any way, we can consider that step irrelevant When y is instantiated, its internal Prototype is being set to Object. Prototype which is an Object object too.
Its constructor ( Object ) is then being called in a context of this newly created object as well, but nothing happens there either So now you end up with 2 Object objects which only differ in that their internal Prototype's reference different objects x s one references whatever you assigned to fn. Prototype and y s references Object. Prototype Their internal Class properties are identical too (i.e.
Equal to "Object") You can't get direct access to Prototype in ES3. You can infer something about it by using instanceof but since fn is nulled in your example intanceof based inference is out of the picture Now, you can augment Object constructor in such way that it would somehow mutate instantiated object. You can then inspect an object and detect this augmentation.
For example: Object = function() { return ({ __: void 0 }); } and then: function isNewObject(object) { return '__' in object; } but this will, of course, only work when object is being created with new Object and not via, say, an object literal { } It's also rather obtrusive :) Perhaps there are other ways, but I can't see them right now HTH.
I'm pretty sure you can't do this in ES3 with only standard support, and here's why: Look at x and y creation. Var fn = function(){}; fn. Prototype = {}; var x = new fn, y = new Object; When x is instantiated, its internal Prototype is being set to an object referenced by fn.
Prototype (just an Object object that you assigned to fn. Prototype). Object's constructor - fn - is then being called in a context of that newly created object, but since it doesn't mutate ab object in any way, we can consider that step irrelevant.
When y is instantiated, its internal Prototype is being set to Object. Prototype, which is an Object object too. Its constructor (Object) is then being called in a context of this newly created object as well, but nothing happens there either.So now you end up with 2 Object objects which only differ in that their internal Prototype's reference different objects - x's one references whatever you assigned to fn.
Prototype and y's references Object.prototype. Their internal Class properties are identical too (i.e. Equal to "Object") You can't get direct access to Prototype in ES3.
You can infer something about it by using instanceof, but since fn is nulled in your example intanceof-based inference is out of the picture. Now, you can augment Object constructor in such way that it would somehow mutate instantiated object. You can then inspect an object and detect this augmentation.
For example: Object = function() { return ({ __: void 0 }); } and then: function isNewObject(object) { return '__' in object; } but this will, of course, only work when object is being created with new Object and not via, say, an object literal - { }. It's also rather obtrusive :) Perhaps there are other ways, but I can't see them right now.HTH.
Your solution would only work if someone doesn't explicitly define `__', but it's seems the only possible way (other than bruteforcing by iterating over properties and using!obj. HasOwnProperty(..) and!Object.prototype. HasOwnProperty(..)) – Eli Grey Aug 14 '09 at 1:33 You can always change "__" to a more unique token, of course, but the problem would still persist.
Any script would be able to spoof Object object by adding/deleting this unique token. – kangax Aug 20 '09 at 4:35.
As far as I know your problem is impossible to solve with ES3: instanceof and isPrototypeOf() can't be used to solve it because the prototype object of fn is inaccessible, and only ES5 allows access to the internal Prototype property via Object.getPrototypeOf(). Btw, an even harder problem to solve would be if you assign Object. Prototype to fn.
Prototype, eg var x = (function() { function Foo() {} Foo. Prototype = Object. Prototype; return new Foo; })(); As the prototype chain of Foo and Object instances is identical, there shouldn't be any way to distinguish them.
When x is instantiated, its internal Prototype is being set to an object referenced by fn. Prototype (just an Object object that you assigned to fn. Object's constructor - fn - is then being called in a context of that newly created object, but since it doesn't mutate ab object in any way, we can consider that step irrelevant.
When y is instantiated, its internal Prototype is being set to Object. Prototype, which is an Object object too. Its constructor (Object) is then being called in a context of this newly created object as well, but nothing happens there either.
So now you end up with 2 Object objects which only differ in that their internal Prototype's reference different objects - x's one references whatever you assigned to fn. Prototype and y's references Object.prototype. Their internal Class properties are identical too (i.e.
You can't get direct access to Prototype in ES3. You can infer something about it by using instanceof, but since fn is nulled in your example intanceof-based inference is out of the picture. Now, you can augment Object constructor in such way that it would somehow mutate instantiated object.
You can then inspect an object and detect this augmentation. But this will, of course, only work when object is being created with new Object and not via, say, an object literal - { }. Perhaps there are other ways, but I can't see them right now.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.