JS高级----------------->原型中使用属性跟方法的时候是怎样进行查找的
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title></title> </head> <body> <script> function Person(name, age, sex) { this.name = name; this.age = age; this.sex = sex; this.eat = function () { console.log(this.name + "在吃饭"); } } Person.prototype.run = function () { console.log(this.name + "在跑步"); }; Person.prototype.age = 19; var per = new Person("Andy", 18, "男"); console.log(per.age);//18 per.run(); /* * 实例对象使用属性和方法时,先在当前对象查询,查询到直接使用,如果查询不到则去原型对象中查找,如果还是查询不到则报错 * */ </script> </body> </html>