YuJian
2 years ago
2 changed files with 29 additions and 1 deletions
@ -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); |
@ -1,3 +1,11 @@ |
|||||||
# learn_example |
# learn_example |
||||||
|
|
||||||
在学习中写过的那些优秀的、有意思的小项目集合 |
在学习中写过的那些优秀的、有意思的小项目集合 |
||||||
|
|
||||||
|
- Axios_Typescript_Encapsulation TypeScript 封装 axios |
||||||
|
- BinarySearch 二叉搜索树 |
||||||
|
- Dynamic programming 动态规划 |
||||||
|
- JavaScript_Sea 对 JavaScript 的一些深入探索尝试 |
||||||
|
- Sorting 排序算法 |
||||||
|
- Structure_LinkedList 数据结构链表的算法练习 |
||||||
|
- Structure_Queue 数据结构队列的算法练习 |
Loading…
Reference in new issue