Ai
1 Star 0 Fork 0

DragonHot/js-code

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
ex5.js 429 Bytes
一键复制 编辑 原始数据 按行查看 历史
DragonHot 提交于 2022-01-10 23:15 +08:00 . 继承
const point = {
x: 1,
y: 2,
arr: [1, 2],
print: function () {
console.log(`Point:(${this.x},${this.y}) ${this.arr}`);
},
};
function ColorPoint(obj) {
function f() {}
f.prototype = obj;
return new f();
}
const cp = ColorPoint(point);
cp.print(); // Point:(1,2) 1,2
cp.arr.push(10086);
const cp2 = Object.create(point);
cp2.print(); // Point:(1,2) 1,2,10086
console.log(cp instanceof ColorPoint); // false
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/dragonhot/js-code.git
git@gitee.com:dragonhot/js-code.git
dragonhot
js-code
js-code
master

搜索帮助