function Shape(x, y) {
this.name = "Shape";
this.move(x, y);
}
Shape.create = function (x, y) {
return new Shape(x, y);
};
Shape.prototype.move = function (x, y) {
this.x = x;
this.y = y;
};
Shape.prototype.area = function () {
return 0;
};
Shape.prototype = {
move: function (x, y) {
this.x = x;
this.y = y;
},
area: function () {
return 0;
},
};
var s = new Shape(0, 0);
var s2 = Shape.create(0, 0);
s.area();
function Circle(x, y, radius) {
Shape.call(this, x, y);
this.name = "Circle";
this.radius = radius;
}
Object.assign(Circle.prototype, Shape.prototype, {
area: function () {
return this.radius * this.radius;
},
});
var c = new Circle(0, 0, 10);
c.area();
class Shape {
static create(x, y) {
return new Shape(x, y);
}
name = "Shape";
constructor(x, y) {
this.move(x, y);
}
move(x, y) {
this.x = x;
this.y = y;
}
area() {
return 0;
}
}
var s = new Shape(0, 0);
var s1 = Shape.create(0, 0);
s.area();
class Circle extends Shape {
constructor(x, y, radius) {
super(x, y);
this.radius = radius;
}
area() {
if (this.radius === 0) return super.area();
return this.radius * this.radius;
}
}
var c = new Circle(0, 0, 10);
c.area();
var x = 0;
var y = 0;
var obj = { x: x, y: y };
var randomKeyString = "other";
var combined = {};
combined["one" + randomKeyString] = "some value";
var obj2 = {
methodA: function () {
console.log("A");
},
methodB: function () {
return 0;
},
};
var x = 0;
var y = 0;
var obj = { x, y };
var randomKeyString = "other";
var combined = {
["one" + randomKeyString]: "some value",
};
var obj2 = {
x,
methodA() {
console.log("A");
},
methodB() {
return 0;
},
};
function add(first, second) {
return first + second;
}
var add = function (first, second) {
return first + second;
};
var add = function add(first, second) {
return first + second;
};
var add = (first, second) => {
return first + second;
};
var self = this;
var addThis = function (first, second) {
return self.value + first + second;
};
var addThis = (first, second) => first + second;
function addNumber(num) {
return function (value) {
return num + value;
};
}
var addNumber = (num) => (value) => num + value;
var addTwo = addNumber(2);
var result = addTwo(4);
class MyClass {
value = 10;
constructor() {
var addThis2 = function (first, second) {
return this.value + first + second;
}.bind(this);
var addThis3 = (first, second) => this.value + first + second;
}
}