大家好,又见面了,我是你们的朋友全栈君。
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script>
class getMsg{
constructor(a,b){
this.x = a;
this.y = b;
}
getNum(){
return this.x * this.y
}
}
var num = new getMsg(2,3);
console.log(num); // getMsg {a: 2, b: 3}
console.log(num.getNum()); // 6
</script>
</body>
</html>
复制代码
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/107475.html原文链接:https://javaforall.cn