JavaScript through for In statement traverses an object

From , 5 Years ago, written in JavaScript, viewed 155 times.
URL https://pastebin.vip/view/4158f6d1
  1. <!DOCTYPE html>
  2. <html>
  3. <body>
  4. <p>sharejs.com Click the button to loop through the properties of an object named "person".</p>
  5. <button onclick="myFunction()">Try it</button>
  6. <p id="demo"></p>
  7.  
  8. <script>
  9. function myFunction()
  10. {
  11. var x;
  12. var txt="";
  13. var person={fname:"John",lname:"Doe",age:25};
  14.  
  15. for (x in person)
  16. {
  17. txt=txt + person[x];
  18. }
  19.  
  20. document.getElementById("demo").innerHTML=txt;
  21. }
  22. </script>
  23. </body>
  24. </html>
  25.  
  26.  
  27. //javascript/7841

Reply to "JavaScript through for In statement traverses an object"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website