Posted By

luizlopes on 11/16/11


Tagged

javascript script in for jslint hasOwnProperty ecma


Versions (?)

Iterating over the properties of an object


 / Published in: JavaScript
 

URL: http://www.jslint.com/lint.html#for%20in

JSLint requires the body of every for in statement should be wrapped in an if statement

  1. var buz = {
  2. fog: 'stack'
  3. };
  4.  
  5. for (var name in buz) {
  6. if (buz.hasOwnProperty(name)) {
  7. alert("this is fog (" + name + ") for sure. Value: " + buz[name]);
  8. }
  9. else {
  10. alert(name); // toString or something else
  11. }
  12. }

Report this snippet  

You need to login to post a comment.