提到js中的面向对象,很多同学就头大,今天我简单的说,你简单的学,轻松~
function Person(name){ ??this.name = name; ?}Person.prototype.say = function(){ ??console.log("我的名字是"+this.name); ?}var finao = new Person("finao");finao.say();
"Person"——大写,作为类。
使用prototype来添加公共属性或者方法。
js中的面向对象
原文地址:https://www.cnblogs.com/amy2017/p/9902587.html