print 'hello world!'"use strict";

/*---
     my first JavaScript *object*

     adapted from "Web Programming: Step by Step", 2nd edition,
     Stepp et al, p. 469

     last modified: 2025-05-06
---*/

// variable person is being set to a JavaScript object

let person = 
    { 
        name: "Philip J. Fry", 
        age: 23, 
        weight: 172.5, 
        friends: ["Farnsworth", "Hermes", "Zoidberg"], 
        getBeloved: function() 
                    { 
                        return this.name + " loves Leela"; 
                    } 
    }; 

window.onload = function()
                {
                    alert("person.age: " + person.age); // 23 
                    alert("person[\"weight\"]: " +
                          person["weight"]);            // 172.5 
                    alert("person.friends[2]: " +
                          person.friends[2]);           // Zoidberg 
                    alert("person.getBeloved(): " +
                          person.getBeloved());   // Philip J. Fry loves Leela 

                    alert("JSON.stringify(person): " +
                          JSON.stringify(person));
                };