原型链-面向面试

总有人问我面试时候原型链怎么写,

作为一位职场老司机,面试界的白神。身经百战,撸出以下的代码

复制代码
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="content-type" content="text/html;charset=utf-8">
    <title>面向面试的原型链</title>
    <link rel="stylesheet" type="text/css" href="">
</head>
<body>
<script>
var interviewer = function(){}
var handsome =function(){}
interviewer.prototype = {}
handsome.prototype = {
    rich : function(){
        console.log('I am very rich')
    },
    handsome:function(){
        console.log('The whole world know that I am handsome ')
    }
}
interviewer.prototype = new handsome;
interviewer.prototype.rich()
interviewer.prototype.handsome()
</script>
</body>
</html>
复制代码

 怎么样,看懂的是不是觉得以上的代码清新脱俗,焕然一新

没看懂的,在这里解释下

首先我定义了interviewer(面试官)和handsome (英俊)2个函数。

然后给他们2个的原型加了点东西,当然主要是handsome加参数,一个rich,一个是handsome

当然I am very rich是川普的名言。。。比起希拉里,我觉得川普上台当米国总统会很有意思。

川普:“你连你老公都满足不了,如何满足米国人民。”  我觉得是米国最霸气的竞选演讲了

好了,以上打住,最后我们将handsome这个玩意new了一下给了面试官。

 

interviewer.prototype = new handsome;

 

然后高富帅满足了2个条件。。。

 

考虑到每个面试官的身高。。。23333(小四也不一定是个例对吧)

 

posted @   一点点白  阅读(1691)  评论(2编辑  收藏  举报
编辑推荐:
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
阅读排行:
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库
点击右上角即可分享
微信分享提示