<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
</body>
</html>
<script type="text/javascript">
{
class Ponit{
/*构造器的作用,初始化类定义的属性和方法*/
constructor(x,y){
this.x=x;
this.y=y;
}
}
/*逻辑值转换字符串*/
Ponit.prototype.getVal=function(){
var res=this.x+this.y;
/*函数出口,把值外面处理*/
return res;
}
var obj = new Ponit(5,8);
console.log( obj.getVal() );
}
</script>
打开App,阅读手记