Martin Honnen
1/11/2015 2:58:00 PM
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 ---