Yep, right, though, in ES3 anyway standard practice was/is to check own properties. And in ES5 you may control enumerable attribute. Besides, I added the line with restoring the constructor only by the habit; in fact I do not use there this check and it's not needed there, so I wouldn't care about it ;)

Dmitry.

On 21.08.2011 0:35, Xavier MONTILLET wrote:
Never thought assigning a new object as prototype was taking that away...
But then when you use for in loops, it is shown whereas it shouldn't...

On Sat, Aug 20, 2011 at 8:10 PM, Dmitry A. Soshnikov
<dmitry.soshni...@gmail.com>  wrote:
On 20.08.2011 7:42, Xavier MONTILLET wrote:
What's the aim of line 69?

https://github.com/DmitrySoshnikov/Essentials-of-interpretation/blob/master/src/lesson-2.js

To restore `constructor` property since we override it when assign to
`prototype`.

var F = function() {};
var f = new F;

console.log(f.constructor == F); // true

// but then
F.prototype = {x: 10};

console.log(f.constructor == F); // false

Details:
http://dmitrysoshnikov.com/ecmascript/chapter-7-2-oop-ecmascript-implementation/

Dmitry.

On Thu, Aug 11, 2011 at 1:46 PM, Dmitry A. Soshnikov
<dmitry.soshni...@gmail.com>    wrote:
Then next step in implementing a small language:

"Essentials of interpretation" Lesson 2. Parsing. Lexer of AE in math
infix
notation.


https://github.com/DmitrySoshnikov/Essentials-of-interpretation/blob/master/src/lesson-2.js

Dmitry.

--
To view archived discussions from the original JSMentors Mailman list:
http://www.mail-archive.com/jsmentors@jsmentors.com/

To search via a non-Google archive, visit here:
http://www.mail-archive.com/jsmentors@googlegroups.com/

To unsubscribe from this group, send email to
jsmentors+unsubscr...@googlegroups.com

--
To view archived discussions from the original JSMentors Mailman list:
http://www.mail-archive.com/jsmentors@jsmentors.com/

To search via a non-Google archive, visit here:
http://www.mail-archive.com/jsmentors@googlegroups.com/

To unsubscribe from this group, send email to
jsmentors+unsubscr...@googlegroups.com


--
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/jsmentors@jsmentors.com/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/jsmentors@googlegroups.com/

To unsubscribe from this group, send email to
jsmentors+unsubscr...@googlegroups.com

Reply via email to