Open lanhsotret opened 4 years ago
function Person(firstName, lastName) { this.first = firstName; this.last = lastName; this.friends = []; }
Person.prototype.addFriend = function(friend) { var NameFriend = this.firstName + ' ' + this.lastName; console.log(NameFriend);// undefined ...... why... this.friends.push(NameFriend); }
var vancanh = new Person('Canh', 'Dinh'); var justin = new Person('Justin', 'Vo'); var micheal = new Person('Micheal', 'Huynh');
vancanh.addFriend(justin); vancanh.addFriend(micheal); console.log(vancanh.friends); // undefined ...why....
function Person(firstName, lastName) { this.first = firstName; this.last = lastName; this.friends = []; }
Person.prototype.addFriend = function(friend) { var NameFriend = this.firstName + ' ' + this.lastName; console.log(NameFriend);// undefined ...... why... this.friends.push(NameFriend); }
var vancanh = new Person('Canh', 'Dinh'); var justin = new Person('Justin', 'Vo'); var micheal = new Person('Micheal', 'Huynh');
vancanh.addFriend(justin); vancanh.addFriend(micheal); console.log(vancanh.friends); // undefined ...why....