Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #23612
| From | Joao Rodrigues <groups_jr-1@yahoo.com.br> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: I get myself in to trouble about "this instanceof function(){}", how "this" will be so this expression values true? |
| Date | 2014-03-21 05:42 -0300 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <lggu2f$8ag$1@speranza.aioe.org> (permalink) |
| References | <d3a07542-8573-4249-80a1-42a340d52c68@googlegroups.com> |
On 21-03-2014 03:06, PinYang Yuen wrote:
> Function.prototype.bind = function(thisObject) {
> var func = this;
> var args = Array.prototype.slice.call(arguments, 1);
> var Nop = function() {}; // Nop: not otherwise provided for
> var bound = function() {
> var a = args.concat(Array.prototype.slice.call(arguments));
> return func.apply(
> this instanceof Nop ? this : thisObject || window, a);
> };
> Nop.prototype = func.prototype;
> bound.prototype = new Nop();
> return bound;
> };
>
> this instanceof Nop ?
>
> Many thanks in advance:-)
>
The right polyfill for Function.prototype.bind (ES5.1, ยง 15.3.4.5) is
given in the following MDN article:
<https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind>
--
Joao Rodrigues
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
I get myself in to trouble about "this instanceof function(){}", how "this" will be so this expression values true? PinYang Yuen <21sanguitar@gmail.com> - 2014-03-20 23:06 -0700
Re: I get myself in to trouble about "this instanceof function(){}", how "this" will be so this expression values true? Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2014-03-21 05:42 -0300
Re: I get myself in to trouble about "this instanceof function(){}", how "this" will be so this expression values true? PinYang Yuen <21sanguitar@gmail.com> - 2014-03-21 02:45 -0700
csiph-web