JSON Examples

2- Object Functions (Getter)

Output

JS

var Person = {
        firstName:  'Joe',
        midName:    'Alan',
        lastName:   'Dokes',
        age:        '35',
        getFirstName: function() {
            return this.firstName;
        }
    }

HTML

<script>
    document.getElementById('info').innerHTML = 
                    Person.getFirstName();
</script>