What does call (this) mean in x.f2.call (this)

function X(){
    return object = {
        name:"object",
        f1(x){
            x.f2.call(this)        
        },
        f2(){
            console.log(this)
        }
    }
}

var options = {
    name:"options",
    f1(){},
    f2(){
        console.log(this)    
    }
}

var x = X()
x.f1(options)
Mar.16,2021

The function of

call is to change the this value of a function call and provide parameters for the function call.

var x = X () , when x is the object object,
x.f1 (options) , because F1 is called as an attribute of the global variable x , when executing x.f1 , the this in the method points to the global variable x , passing in the parameter options .

f1(x){
    x.f2.call(this) // thisxxxxoptions
}

replace the variables in the above code:

options.f2.call(x) // xoptionsthisx
When

options.f2 is executed, because f2 is called as an attribute of options , by default this points to the options object, but call (x) is used, that is, when the method is called, explicitly set this to point to the global variable x :

f2(){
    console.log(this) // thisxx
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1c29cbc-15ed8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1c29cbc-15ed8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?