Thuzi / facebook-node-sdk

Modeled from the (Facebook Javascript SDK), now with the facebook-node-sdk you can now easily write the same code and share between your server (nodejs) and the client (Facebook Javascript SDK).
Other
737 stars 250 forks source link

Supports helper functions added to Array prototype. #51

Closed jlopezr closed 10 years ago

jlopezr commented 10 years ago

If you put some function into the Array prototype the current code fails. This change simply skips the functions when traversing the body Array.

prabirshrestha commented 10 years ago

why would you want to pass a function?

jlopezr commented 10 years ago

I am not passing a function. I add some functions to the prototype of the Array, for example:

Array.prototype.getUnique = function() { var o = {}, a = [], i, e; for (i = 0; e = this[i]; i++) {o[e] = 1}; for (e in o) {a.push (e)}; return a; }

When you iterate over the elements of an array using a for-in, you get the "getUnique" element...

2014-03-20 16:04 GMT+01:00 Prabir Shrestha notifications@github.com:

why would you want to pass a function?

Reply to this email directly or view it on GitHubhttps://github.com/Thuzi/facebook-node-sdk/pull/51#issuecomment-38177722 .

louisameline commented 10 years ago

The best way to iterate on enumerable properties of arrays is for (var i=0, l=myStringArray.length; i<l; i++) { ... }. Although the present PR would work, I've opened this one https://github.com/Thuzi/facebook-node-sdk/pull/57

louisameline commented 10 years ago

This can be closed since my request was merged in.