总有人问我面试时候原型链怎么写,css
做为一位职场老司机,面试界的白神。身经百战,撸出如下的代码html
<!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个函数。ui
而后给他们2个的原型加了点东西,固然主要是handsome加参数,一个rich,一个是handsome
spa
固然I am very rich是川普的名言。。。比起希拉里,我以为川普上台当米国总统会颇有意思。prototype
川普:“你连你老公都知足不了,如何知足米国人民。” 我以为是米国最霸气的竞选演讲了code
好了,以上打住,最后咱们将handsome这个玩意new了一下给了面试官。htm
interviewer.prototype = new handsome;
而后高富帅知足了2个条件。。。blog
考虑到每一个面试官的身高。。。23333(小四也不必定是个例对吧)