Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #14723
| From | Andreas Bergmaier <andber93@web.de> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: why is this function used in conjunction with Object.create? |
| Date | 2012-06-27 23:09 +0200 |
| Organization | albasani.net |
| Message-ID | <jsfsqp$rle$1@news.albasani.net> (permalink) |
| References | <a5d2849f-7e1d-45a4-9eb6-2d3b8eb4e820@googlegroups.com> <V7o0z0Hsiy6PFw2w@J.A830F0FF37FB96852AD08924D9443D28E23ED5CD> <4feb4b76$0$6946$e4fe514c@news2.news.xs4all.nl> <2b1b8713-c63e-4edd-9c8c-3f1f3956706f@googlegroups.com> |
von kristoff schrieb:
>
>>> if (typeof Object.create !== "function") {
>>> Object.create = function (o) {
>>> function F() {}
>>> F.prototype = o;
>>> return new F();
>>> };
>>> }
>
> ... but my javascript version allows me to write it without having to declare that function...
That just means you're one of the lucky. For those with older browsers
and javascript versions that don't support it (then typeof Object.create
is not "function", but "undefined"), this snippets adds (a part of) the
functionality of the native Object.create (see also
https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/create/).
Bergi
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
why is this function used in conjunction with Object.create? von kristoff <mrjcnicolas@gmail.com> - 2012-06-27 08:09 -0700
Re: why is this function used in conjunction with Object.create? John G Harris <john@nospam.demon.co.uk> - 2012-06-27 16:37 +0100
Re: why is this function used in conjunction with Object.create? "Tom de Neef" <tdeneef@qolor.nl> - 2012-06-27 20:04 +0200
Re: why is this function used in conjunction with Object.create? von kristoff <mrjcnicolas@gmail.com> - 2012-06-27 11:50 -0700
Re: why is this function used in conjunction with Object.create? Andreas Bergmaier <andber93@web.de> - 2012-06-27 23:09 +0200
Re: why is this function used in conjunction with Object.create? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-06-30 11:06 +0200
Re: why is this function used in conjunction with Object.create? John G Harris <john@nospam.demon.co.uk> - 2012-06-28 11:10 +0100
Re: why is this function used in conjunction with Object.create? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2012-06-29 16:25 -0700
csiph-web