<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>oop</title>
<script charset="utf-8" type="text/javascript">
function Person() {
}
Person.prototype = {
name : 'Lucy',
age : 23,
friends : ['Kinsey','Godwin','David'],
sayHello: function () {
document.write('hi,boy' + '<br><br>');
}
};
var p = new Person();
var p2= new Person();
document.write(p.sayHello());
p.friends.push('Berkhoom');
document.write(p.friends + '<br><br>');
document.write(p2.friends + '<br><br>');
</script>
</head>
<body>
</body>
</html>
**hi,boy
undefinedKinsey,Godwin,David,Berkhoom
Kinsey,Godwin,David,Berkhoom **
I don't kown where the word undefined comes from? help?
p.fiendsarray:console.log(p.friends). I think you have first element empty (removed it?)undefinedis the standard return type for a function, likesayHello. You don't need to write the output ofsayHello. Replacedocument.write(p.sayHello());withp.sayHello();