Posted By

noah on 06/11/07


Tagged

object library trim String hash utilities keys


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

vali29
metoikos


keys: get an array of all property names in an object


 / Published in: JavaScript
 

do the same thing as the Perl "keys" subroutine

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: bwagner on January 16, 2011

The above code does not work. Replace arr with accumulator.

//do the same thing as the Perl "keys" subroutine keys : function (o) { var accumulator = []; for (var propertyName in o) { accumulator.push(propertyName); } return accumulator; }

//get values instead of keys values : function (o) { var accumulator = []; for (var propertyName in o) { accumulator.push(o[propertyName]); } return accumulator; }

Posted By: Jacky888 on August 6, 2018

myditto firmware gofirmware

You need to login to post a comment.