/ Published in: JavaScript
do the same thing as the Perl "keys" subroutine
Expand |
Embed | Plain Text
//do the same thing as the Perl "keys" subroutine keys : function (o) { var accumulator = []; for (var propertyName in o) { arr.push(propertyName); } return accumulator; } //get values instead of keys values : function (o) { var accumulator = []; for (var propertyName in o) { arr.push(o[propertyName]); } return accumulator; }
Comments
Subscribe to comments
You need to login to post a comment.

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; }