Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #26548
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Can somebody give me an example how I can call this forEachIn function |
| Date | 2015-01-11 17:43 +0100 |
| Organization | PointedEars Software (PES) |
| Message-ID | <21533753.SDDzv5OC2z@PointedEars.de> (permalink) |
| References | <m8rcir$9u1$1@dont-email.me> <m8u310$2bao$1@adenine.netfront.net> |
Martin Honnen wrote:
> Tony Johansson wrote:
>> function forEachIn(object, action)
>> {
>> for(var property in object)
>> {
>> if (object.hasOwnProperty(property))
>> {
>> action(property, object[property]);
>> }
>> }
>> }
>
> For instance,
>
> var obj = { prop1: 'foo', prop2: 42 };
>
> forEachIn(obj, function(propName, propValue) {
> console.log(propName + ' has value "' + propValue + '"');
> });
>
> will output
>
> prop1 has value "foo"
> prop2 has value "42"
The for-in iteration order is not defined, so the lines above could be
reversed.
> --- news://freenews.netfront.net/ - complaints: news@netfront.net ---
I strongly suggest not to use that service, it is a major source of trolls.
--
PointedEars
FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix>
Please do not cc me. / Bitte keine Kopien per E-Mail.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Find similar | Unroll thread
Can somebody give me an example how I can call this forEachIn function "Tony Johansson" <johansson.andersson@telia.com> - 2015-01-10 15:22 +0100
Re: Can somebody give me an example how I can call this forEachIn function Martin Honnen <mahotrash@yahoo.de> - 2015-01-11 15:57 +0100
Re: Can somebody give me an example how I can call this forEachIn function Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-01-11 17:43 +0100
csiph-web