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

     

  • 相关阅读:
    TestNG入门教程-6-enabled和priority属性
    TestNG入门教程-5-timeOut属性
    TestNG入门教程-4-Testng中注释简介
    Unicode、UTF-8 和 ISO8859-1到底有什么区别
    java数目
    sql必知必会-总结篇
    mysql监控、性能调优及三范式理解
    loadrunner常用函数总结
    loadrunner监控度量项及中文解释
    linux下crontab的使用实现
  • 原文地址:https://www.cnblogs.com/LoveOrHate/p/5992867.html
Copyright © 2011-2022 走看看