Right click > Select "View Page Source" to see source code.
EXAMPLE 1:
// Example JS Class
class Rectangle {
constructor(height, width) {
this.height = height;
this.width = width;
}
// Getter
get area() {
return this.calcArea();
}
// Method
calcArea() {
return this.height * this.width;
}
}
const square = new Rectangle(10, 10);
console.log(square.area); //100
EXAMPLE 2:
// Example JS Clamp polyfill
function clamp(num, min, max) {
// returns a num if between the min and max. If num is greater than max, it returns max, if num is less than min, it returns min
return num <= min ? min : num >= max ? max : num;
}