The Now Platform® Washington DC release is live. Watch now!
Yesterday I showed you how to figure out whether an object had a certain property. But suppose you didn't know ahead of time which property you wanted? Then what you'd want to do is to enumerate all the properties in the object, to see what you've got.
Surely that's beyond anything JavaScript can do, right? Wrong!
If I run this code:
var whazzis = {};
whazzis.who = 'you';
whazzis.why = 'who knows';
whazzis.when = 'back then';
whazzis.where = 'over there';
whazzis.what = 'dunno';
for (var name in whazzis) {
gs.log(name + ': ' + whazzis[name]);
}
what: dunno
why: who knows
who: you
where: over there
when: back then
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.