javascript Js - 面向对象编程

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript Js - 面向对象编程相关的知识,希望对你有一定的参考价值。

function Person(fullName, favColor) {
	this.name = fullName;
	this.favoriteColor = favColor;
	this.greet = function (){
		console.log('Hello, my name is '+ this.name + ' and my favorite color is ' + this.favoriteColor '.');
	}
}

var john = new Person('John Doe', 'blue');
john.greet();

var jane = new Person('Jane Smith', 'green');
jane.greet();

以上是关于javascript Js - 面向对象编程的主要内容,如果未能解决你的问题,请参考以下文章

javascript Js - 面向对象编程

JavaScript面向对象编程

Javascript 进阶 面向对象编程 继承的一个例子

快速理解JavaScript面向对象编程—原型继承

JavaScript (JS) 面向对象编程 浅析 (含对象函数原型链解析)

javascript的面向对象的编程介绍书籍都有哪些