Public
Edited
May 13, 2023
Insert cell
Insert cell
circle = {
return {
radius: 5,
center: [0, 0],
area() {
return Math.PI * Math.pow(this.radius, 2);
},
transition(vector) {
this.center[0] += vector[0];
this.center[1] += vector[1];
},
concentric(cir) {
if (cir.center.toString() == this.center.toString()) {
return true;
}

return false;
},
coincide(cir) {
if (this.concentric(cir) && cir.radius == this.radius) {
return true;
}

return false;
}
};
}
Insert cell
{
console.log("半径:"+ circle["radius"]);
console.log("面积:"+ circle.area());

circle.transition([1, 2])
console.log("移动后的圆心:"+ circle.center.x);

let testCircle = {
radius: 5,
center: [1, 2],
};

console.log("同心:" + circle.concentric(testCircle));
console.log("重合:" + circle.coincide(testCircle));
}
Insert cell
Insert cell
{
console.log(circle);
}
Insert cell
{
let obj = circle;

console.log(circle.constructor())
}
Insert cell
{
let obj = new Number(1);
obj.toString = () => {
return 2;
}

return obj.toString()
}
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more