Loading ...
Sorry, an error occurred while loading the content.

586Re: json.js breaks for-in loops

Expand Messages
  • Stephen M. McKamey
    Nov 13 4:16 PM
    • 0 Attachment
      --- In json@yahoogroups.com, Tom Metro <tmetro+json@...> wrote:
      > Peter Michaux wrote:
      > > By extending the Object.prototype with the new property
      toJSONString I
      > > can no longer use for-in loops in my JavaScript.
      > As another poster mentioned, using hasOwnProperty(), is the way to
      > the intended behavior work. My understanding is that hasOwnProperty()
      > isn't widely supported yet.

      A little late to the conversation but... another alternative could be
      to use the typeof operator (assuming one was iterating over data):

      for(k in obj)
      if("function"!=typeof obj[k])

    • Show all 10 messages in this topic