Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #23611 > unrolled thread
| Started by | PinYang Yuen <21sanguitar@gmail.com> |
|---|---|
| First post | 2014-03-20 23:06 -0700 |
| Last post | 2014-03-21 02:45 -0700 |
| Articles | 3 — 2 participants |
Back to article view | Back to comp.lang.javascript
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
| From | PinYang Yuen <21sanguitar@gmail.com> |
|---|---|
| Date | 2014-03-20 23:06 -0700 |
| Subject | I get myself in to trouble about "this instanceof function(){}", how "this" will be so this expression values true? |
| Message-ID | <d3a07542-8573-4249-80a1-42a340d52c68@googlegroups.com> |
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:-)
[toc] | [next] | [standalone]
| From | Joao Rodrigues <groups_jr-1@yahoo.com.br> |
|---|---|
| Date | 2014-03-21 05:42 -0300 |
| Message-ID | <lggu2f$8ag$1@speranza.aioe.org> |
| In reply to | #23611 |
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
[toc] | [prev] | [next] | [standalone]
| From | PinYang Yuen <21sanguitar@gmail.com> |
|---|---|
| Date | 2014-03-21 02:45 -0700 |
| Message-ID | <cbdb6270-c0b8-4c1b-9749-48ac99dc96f9@googlegroups.com> |
| In reply to | #23612 |
在 2014年3月21日星期五UTC+8下午4时42分56秒,J.R.写道:
> 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
thanks. I found i don't make myself clear. The real problem is how instanceof op works? I finally figure it out.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web