Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #7607
| From | "J.R." <groups_jr-1@yahoo.com.br> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: How Array.prototype.forEach Works (Test Before Explaining) |
| Date | 2011-10-21 11:27 -0700 |
| Organization | http://groups.google.com |
| 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> |
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
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