problem Getting the keys alone from Associative array ? for (var key in AssociativeArray) returns all the keys and its prototype members..

I am having small problem in my JS where i need to iterate through all the keys in the associative array. var listOfKeys=new Array(); for (var key in parsedArray) { listOfKeys.push(key); } It works perfectly and returns all the properties associated to the object. Now i have a situation to add the prototype method to an array, Array.prototype.ModifyKey= function(key,value){ //some code } so now the parsedArray is eligible to access this new prototype ModifyKey (actually ModifyKey is a member to all my arrays). Now when i loop through the parsedArray to find all the keys, it returns all the keys along with the prototypes associated with that... is there a better way to overcome this.. *I know some workarounds like, having the parsedArray as simplearray which holds the array of key value pairs to get the keys without this problem. But the input array am getting is not in my control, its a json result from the another REST service.*

以上就是problem Getting the keys alone from Associative array ? for (var key in AssociativeArray) returns all the keys and its prototype members..的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏