
您可以在 %ignore_a_1%hub 仓库中找到这篇文章中的所有代码。
背包客旅行扁平网站模板
背包客(Backpacker),又称驴友,泛指三五成群或者单枪匹马四处游逛的人,也就是背着背包做长途自助旅行的人,现主要是以群体登山、徒步、探险等寻找刺激的人为主,目的在于通过游历认识世界,认识自我,挑战极限等。[1] 驴友一般喜结伴出行,有的准备有帐篷、睡袋,露宿在山间旷野。另一种说法是,取自”旅友”的谐音,即旅行之友的意思。台湾多称呼他们为自助旅行玩家或自助旅游者,香港
43 查看详情
oop 相关挑战
实例化
/** * @param {any} obj * @param {target} target * @return {boolean} */// one-line solutionfunction myinstanceof(obj, fn) { return fn.prototype.isprototypeof(obj);}function myinstanceof(obj, fn) { if (typeof obj !== "object" || obj === null) { return false; } if (typeof fn !== "function") { return false; } let proto = object.getprototypeof(obj); while (proto) { if (proto === fn.prototype) { return true; } proto = object.getprototypeof(proto); } return false;}// usage exampleclass a {}class b extends a {}const b = new b();console.log(myinstanceof(b, b)); // => trueconsole.log(myinstanceof(b, a)); // => trueconsole.log(myinstanceof(b, object)); // => truefunction c() {}console.log(myinstanceof(b, c)); // => falsec.prototype = b.prototype;console.log(myinstanceof(b, c)); // => truec.prototype = {};console.log(myinstanceof(b, c)); // => false
新的
/** * @param {Function} constructor * @param {any[]} args * `myNew(constructor, ...args)` should return the same as `new constructor(...args)` */function myNew(constructor, ...args) { const obj = {}; Object.setPrototypeOf(obj, constructor.prototype); const result = constructor.call(obj, ...args); if (typeof result !== "object" || result == null) { return obj; } else { return result; }}// Usage examplefunction Person(name) { this.name = name;}const person = myNew(Person, "Mike");console.log(person); // => Person { name: 'Mike' }
参考
60。创建您自己的新运算符 – bfe.dev90。编写你自己的实例 – bfe.dev实例 – mdn新 – mdn方法链 – wikipedia.org2726。带方法链的计算器 – leetcode
以上就是OOP – JavaScript 挑战的详细内容,更多请关注创想鸟其它相关文章!
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 chuangxiangniao@163.com 举报,一经查实,本站将立刻删除。
发布者:程序猿,转转请注明出处:https://www.chuangxiangniao.com/p/895428.html
微信扫一扫
支付宝扫一扫