class Name
end и что такое def Name
@var = var
enddeffunction Name() {}@var, думал сперва, что это что-то типа returnfunction Name() { return var = 1; } <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<script>
"use strict";
class Polygon {
constructor(height, width) {
this.height = height;
this.width = width;
}
calcArea() {
return this.height * this.width;
}
}
var p = new Polygon(10, 20);
alert("height = " + p.height + ", width = " + p.width + ", area = " + p.calcArea());
</script>
</body>
</html>