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


Groups > comp.lang.javascript > #26531 > unrolled thread

Can somebody give me an example how I can call this forEachIn function

Started by"Tony Johansson" <johansson.andersson@telia.com>
First post2015-01-10 15:22 +0100
Last post2015-01-11 17:43 +0100
Articles 3 — 3 participants

Back to article view | Back to comp.lang.javascript


Contents

  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

#26531 — Can somebody give me an example how I can call this forEachIn function

From"Tony Johansson" <johansson.andersson@telia.com>
Date2015-01-10 15:22 +0100
SubjectCan somebody give me an example how I can call this forEachIn function
Message-ID<m8rcir$9u1$1@dont-email.me>
Just specify some variables or object so I can uderstand hiw this forEachIn 
can be called

function forEachIn(object, action)
    {
        for(var property in object)
        {
            if (object.hasOwnProperty(property))
            {
                action(property, object[property]);
            }
        }
    }

//Tony 

[toc] | [next] | [standalone]


#26543 — Re: Can somebody give me an example how I can call this forEachIn function

FromMartin Honnen <mahotrash@yahoo.de>
Date2015-01-11 15:57 +0100
SubjectRe: Can somebody give me an example how I can call this forEachIn function
Message-ID<m8u310$2bao$1@adenine.netfront.net>
In reply to#26531
Tony Johansson wrote:
> Just specify some variables or object so I can uderstand hiw this
> forEachIn can be called
>
> 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"


--- news://freenews.netfront.net/ - complaints: news@netfront.net ---

[toc] | [prev] | [next] | [standalone]


#26548 — Re: Can somebody give me an example how I can call this forEachIn function

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2015-01-11 17:43 +0100
SubjectRe: Can somebody give me an example how I can call this forEachIn function
Message-ID<21533753.SDDzv5OC2z@PointedEars.de>
In reply to#26543
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.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web