Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #7607

Re: How Array.prototype.forEach Works (Test Before Explaining)

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news.glorb.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
From "J.R." <groups_jr-1@yahoo.com.br>
Newsgroups comp.lang.javascript
Subject Re: How Array.prototype.forEach Works (Test Before Explaining)
Date Fri, 21 Oct 2011 11:27:32 -0700 (PDT)
Organization http://groups.google.com
Lines 29
Message-ID <12981089.341.1319221652655.JavaMail.geo-discussion-forums@yqoo7> (permalink)
References <f711147c-c7a2-4c09-843b-6e4abe411ce9@t38g2000prg.googlegroups.com> <84b0c9d9-da16-4a25-9ed4-13c9c770156e@v33g2000prm.googlegroups.com>
Reply-To comp.lang.javascript@googlegroups.com
NNTP-Posting-Host 189.25.9.89
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
X-Trace posting.google.com 1319221771 20778 127.0.0.1 (21 Oct 2011 18:29:31 GMT)
X-Complaints-To groups-abuse@google.com
NNTP-Posting-Date Fri, 21 Oct 2011 18:29:31 +0000 (UTC)
In-Reply-To <84b0c9d9-da16-4a25-9ed4-13c9c770156e@v33g2000prm.googlegroups.com>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=189.25.9.89; posting-account=17htbAoAAACg7n33Vobs5LZosCMM2vTt
User-Agent G2/1.0
X-Google-Web-Client true
Xref x330-a1.tempe.blueboxinc.net comp.lang.javascript:7607

Show key headers only | View raw


On Friday, 21 October 2011 03:47:47 UTC-2, dhtml  wrote:
> On Oct 20, 10:30 pm, dhtml <dhtmlk...@gmail.com> wrote:
> > The `this` value in the callback function in Array.prototype.forEach
> > is the array itself.
> >
> > http://es5.github.com/#x15.4.4.18
> >
> > Unfortunately, the author of what will be another book on JavaScript
> > doesn't want know that.
> 
> Well it turns out I was wrong.
> 
> "If a thisArg parameter is provided, it will be used as the this value
> for each invocation of callbackfn. If it is not provided, undefined is
> used instead."

Hi,
I prefer the MDN's definition at
<https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/forEach>

"If a thisArg parameter is provided to forEach, it will be used as the this value for each callback invocation as if callback.call(thisArg, element, index, array) was called. If thisArg is undefined or null, the this value within the function depends on whether the function is in strict mode or not (passed value if in strict mode, global object if in non-strict mode)."

Cheers,
JR

Back to comp.lang.javascript | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

How Array.prototype.forEach Works (Test Before Explaining) dhtml <dhtmlkitchen@gmail.com> - 2011-10-20 22:30 -0700
  Re: How Array.prototype.forEach Works (Test Before Explaining) dhtml <dhtmlkitchen@gmail.com> - 2011-10-20 22:47 -0700
    Re: How Array.prototype.forEach Works (Test Before Explaining) "J.R." <groups_jr-1@yahoo.com.br> - 2011-10-21 11:27 -0700

csiph-web