Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
</body>
</html>
 
var peopleJson = [
  {
     "name": "Alice",
     "age": 28
  },
  {
     "name": "Bob",
     "age": 33
  }
];
var people = [];
var Person = (function () {
    function Person(person) {
        this.person = person;
        this.name = person.name;
        this.age = person.age;
    }
    Person.prototype.introduce = function () {
        return "My name is " + this.name + " and I am " + this.age + " years old.";
    };
    return Person;
})();
for (var i = 0, len = peopleJson.length; i < len; i++) {
  people.push(new Person(peopleJson[i]));
  console.log(people[i].introduce());
}
console.log(Object.prototype.introduce);
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers