JS构造函数

Posted 苹果园dog

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了JS构造函数相关的知识,希望对你有一定的参考价值。

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<script>
function LayerPoperty(cloudType,version,lineId,modelChunk) {
this.cloudType=cloudType;
this.version=version;
this.lineId=lineId;
this.modelChunk=modelChunk;
}
LayerPoperty.prototype.getVersion=function () {
return this.version;
}
var p=new LayerPoperty("wire",2017,435,‘1-200‘);
alert(p.getVersion());
</script>
</body>
</html>





















以上是关于JS构造函数的主要内容,如果未能解决你的问题,请参考以下文章

js构造函数

JS:构造函数

JS中构造函数与普通函数的区别及JS构造函数原型和实例的关系

js原型和构造函数

JS构造函数

JS中构造函数、实例、原型对象之间的关系