I have created a bug for this: http://code.google.com/p/v8/issues/detail?id=697
I can, however, also reproduce this on windows. Andrey, if possible, could you state which version of chrome this was performed in on all platforms? Also, could you please state if it was 32 or 64 bit versions of chrome? Rico On Tue, Apr 27, 2010 at 9:55 PM, Ondřej Žára <[email protected]> wrote: > Hi Andrey, > > I have no idea why this inconsistent behavior is present. I am, however, > interested in your use case, beucase I do not see any good in passing a > function to Object.create. Typically, one does > > var Parent = function() {}; > var Child = function() {}; > Child.prototype = Object.create(Parent.prototype); /* inheritance without > constructor execution */ > > So I wonder if your interest is based on curiosity, or some real-life > implementation where it is desirable to call Object.create(function(){}). > Note that weird things can happen: > > var F = function() {}; > F.prototype = function() {}; > var f = new F(); > "apply" in f; // true! you just "inherited" a function :) > > > > Ondrej > > > > > > 2010/4/27 Andrey Fedorov <[email protected]> >> >> When playing with some JS in Chrome, I noticed that the native >> implementation of Object.create throws a TypeError exception (Object >> prototype may only be an Object or null) if a function object is passed in, >> like: >> Object.create(function () {}) >> The error is both factually incorrect and inconsistent with Crockford's >> original implementation, which works fine, if you pass in a function (even >> in Chrome): >> Object.create = function (o) { >> function F() {} >> F.prototype = o; >> return new F(); >> }; >> Oddly enough, I'm only seeing this on the Linux and OSX versions of >> Chrome, not on Windows. Any ideas why this could be? >> - Andrey >> >> -- >> v8-users mailing list >> [email protected] >> http://groups.google.com/group/v8-users > > -- > v8-users mailing list > [email protected] > http://groups.google.com/group/v8-users -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users
