From 00e894dd4b9ea9017cfd6f78eb8c1e9c60c82130 Mon Sep 17 00:00:00 2001 From: YuJian Date: Wed, 29 Jun 2022 16:26:05 +0800 Subject: [PATCH] =?UTF-8?q?JS=E6=B7=B1=E5=85=A5=E6=8E=A2=E7=B4=A2=20?= =?UTF-8?q?=E6=A8=A1=E6=8B=9Fnew?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- JavaScript_Sea/new.ts | 20 ++++++++++++++++++++ README.md | 10 +++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 JavaScript_Sea/new.ts diff --git a/JavaScript_Sea/new.ts b/JavaScript_Sea/new.ts new file mode 100644 index 0000000..f62064e --- /dev/null +++ b/JavaScript_Sea/new.ts @@ -0,0 +1,20 @@ +/** + * @description 模拟 new + * @date 2022-06-29 + */ + +function Op1(name, age) { + this.name = name; + this.age = age; +} + +function myNew(obs: any, ...args) { + const newObject = Object.create(obs.prototype); + const returnObj = obs.apply(newObject, args); + + if (!(returnObj instanceof Object)) return newObject; + else return returnObj; +} + +const ex1 = myNew(Op1, 1, 1); +console.log("ex1", ex1); diff --git a/README.md b/README.md index f8ee54b..d48094f 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,11 @@ # learn_example -在学习中写过的那些优秀的、有意思的小项目集合 \ No newline at end of file +在学习中写过的那些优秀的、有意思的小项目集合 + +- Axios_Typescript_Encapsulation TypeScript 封装 axios +- BinarySearch 二叉搜索树 +- Dynamic programming 动态规划 +- JavaScript_Sea 对 JavaScript 的一些深入探索尝试 +- Sorting 排序算法 +- Structure_LinkedList 数据结构链表的算法练习 +- Structure_Queue 数据结构队列的算法练习 \ No newline at end of file