//call的实现
Function.prototype.call2 = function (content = window) {

    content.fn = this
    var result = content.fn(...Array.prototype.slice.call(arguments).slice(1));
    delete content.fn
    return result
}

const son = {
   name: 'son',
   test: function() {
       console.log(this.name +"你好,这里是test对象")
   }
}
function person (a, b) {
    var name = 'person'
    console.log(a, b)
}
person.call2(son, 'call', '123')

//apply的实现
Function.prototype.apply2 = function (content=window) {
    content.fn = this
    if (arguments.length > 2) {
        throw new Error('必须传入两个参数')
    }
    if (Object.prototype.toString.call(arguments[1]) !== '[object Array]') {
        throw new Error('第二个参数为数组')
        return 
    }
    var result = content.fn(Array.prototype.slice.call(arguments).slice(1));
    delete content.fn
    return result
}
 const son = {
   name: 'son',
   test: function() {
       console.log(this.name +"你好,这里是test对象")
   }
}
function person (a) {
    var name = 'person'
    console.log(a)
    this.test()
}
person.apply2(son, ['call', '123'])