zoukankan      html  css  js  c++  java
  • 原型链-面向面试

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

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

    <!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(小四也不一定是个例对吧)

     

  • 相关阅读:
    SQL大语句——实现分页,select top后面跟变量出错
    jQuery异步请求(如getJSON)跨域解决方案
    Debug常用命令
    清华操作系统实验--80x86汇编基础
    在Windows10中运行debug程序
    恢复Windows10应用商店
    最少硬币问题
    嵌套矩形问题
    清华大学操作系统实验准备--挖坑
    动态规划入门-数字三角形
  • 原文地址:https://www.cnblogs.com/LoveOrHate/p/5992867.html
Copyright © 2011-2022 走看看