JSFiddle - React, Tailwind, and code Playground
JavaScript
function World() {
this.mankind = new Mankind(this);
this.getName = function(id) {
console.log('getName', this);
return this.mankind.people[id].name;
}
alert(this.getName(0));
this.tmpString = '';
for(var i = 0; i < this.mankind.city.length; i++)
{
this.tmpString += this.getName(i) + ' ';
}
alert('Здесь проживают: ' + this.tmpString);
}
function Mankind(world) {
this.people = new Array();
this.people[0] = new Man(this, 'Vasily');
this.people[1] = new Man(this, 'Alessandra');
this.city = [0, 1];
}
function Man(mankind, name) {
this.name = name;
}
new World();