2011/4/2 Dmitry A. Soshnikov <dmitry.soshni...@gmail.com>: > On 03.04.2011 1:38, Poetro wrote: >> >> 2011/3/29 alexis<acoudey...@gmail.com>: >>> >>> var k = null; >>> Object(k) === k --> false (in Chrome and FF4). >>> >>> I don't understand how this behavior is consistent with ES5 spec. >>> In >>> http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf, >>> 15.2.1 and 15.2.1.1, seems to indicate that Object(null) is the same >>> as new Object(null). 15.2.2.1 specify that : >>> - if type(value) is object (and null is of type object in js) >>> - and if value is a native ES object (null should be), do not create a >>> new object but simply return value. >>> >>> Am i missing something ? >> >> Object(k) returns a new object whatever k was it doesn't mind. > > If k is an object it just returns it as is without any transformation. > > var s = new String("hello"); > > console.log(Object(s) === s); // true
Yes, sorry, if k is a primitive type or anything that is not derived from Object (like null, which doesnt have any Object properties). -- Poetro -- 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