映客二面

关于原型链的输出判断

var name = 'oop'

        var Person = function (options) {
            this.name = options.name
        }

        Person.prototype.name = 'Person'
        Person.prototype.getName = function () {
            return this.name
        }

        Person.getName = function () {
            return this.name;
        }

        var p = new Person({ name: 'inke' })

        console.log(p.constructor === Person) // true
        console.log(p instanceof Person) // true
        console.log(p.__proto__ === Person.prototype) // true

        console.log(p.hasOwnProperty('name')) // true
        console.log(p.hasOwnProperty('getName')) // false

        var getName = p.getName

        console.log(getName === Person.getName) // ? false

        console.log(getName()) //  oop

        console.log(Person.prototype.getName()) // ? 'Person'
        console.log(p.getName())  //  'inke' 
        console.log(Person.getName())//  Person
#设计美术##映客##笔经#
全部评论
楼主,二面后有消息吗?
点赞 回复
分享
发布于 2021-09-26 13:52
跟我问的一样 全是输入输出题
点赞 回复
分享
发布于 2021-09-29 22:24
乐元素
校招火热招聘中
官网直投
老哥,投递简历几天有笔试
点赞 回复
分享
发布于 2021-10-03 18:26

相关推荐

点赞 评论 收藏
转发
点赞 3 评论
分享
牛客网
牛客企业服务