Home
<!DOCTYPE html> <html> <body> <h1>Demo: JavaScript Object using for-in Loop</h1> <script> var person = new Object(); person.firstName = "James"; person.lastName = "Bond"; for(var prop in person){ alert(prop); // access property name alert(person[prop]); // access property value }; </script> </body> </html>
Result: