
本文共 2160 字,大约阅读时间需要 7 分钟。
JavaScript������new���������������������
���JavaScript������������new������������������������������������������������������������������������������������������������������������new������������������������������������������������������������������������������������������
New������������������������������������������������������������������������������������������������������������������������������������������������������Java���new���������������������������JavaScript���������������new������������������������������������
���������������������������������������������������new������������������������������������������������������������������������������Person���������������������
function Person(name, age) { this.name = name; this.age = age; this.habit = 'Games';}Person.prototype.strength = 60;Person.prototype.sayYourName = function() { console.log('I am ' + this.name);};function myNew(fn, ...args) { // ��������������������������������������������������������������� let obj = new Object(); // ��������������������������������������������������������� let F = function() {}; F.prototype = fn.prototype; // ��������������������������������������������������������������� let ret = fn.apply(obj, args); // ��������������������������������������������������� return typeof ret === 'object' ? ret : obj;}
������������������������������������������������������new������������������������������������������������������new������������������������������������ prototype���������������������������
��������������������������������� ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
���������������new������������������������������������������������������������������������������������������������������������������������������������������������������new������������������������������������������������������������JavaScript������������������������������������������������������������������������������������������������������������������������������������������������������������
发表评论
最新留言
关于作者
