题解 | #Getter#

Getter

https://www.nowcoder.com/practice/e7f3a2f429d945e49f5b48ef1065beda

本题考点:class、Getter取值函数

核心步骤:

  1. 创建Rectangle类,在默认方法constructor中写入width,heigh参数(当new Rectangle执行)
  2. 创建Getter area取值函数,获取area时返回乘积
<script type="text/javascript">
 	class Rectangle {
		constructor(height, width) {
		  this.height = height
		  this.width = width
		}
	  get area() {
		  return this.height * this.width
	  }
	}
</script>

全部评论

相关推荐

10-28 10:48
已编辑
门头沟学院 Java
孩子我想要offer:发笔试后还没笔试把我挂了,然后邮箱一直让我测评没测,后面不知道干嘛又给我捞起来下轮笔试,做完测评笔试又挂了😅
点赞 评论 收藏
分享
评论
1
1
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务