Problems in the use of setInterval function in js

function Test(){
    this.func1=function(){
        console.log("func1")
    }
    this.func2=function(){
        console.log("func2")
    }
    this.func3=function(){
        console.log("func3")
    }
    this.all=function(){
        console.log(this)
        this.func1()
        this.func2()
        this.func3()
    }
}
var test=new Test()
test.all()//thisfunc1func2func3
setInterval(test.all,1000)//thiswindow

Why does this suddenly point to window? in the setInterval (test.all,1000) statement?

the code I am writing now requires the statement setInterval (test.all,1000) . How can I make the code work properly?

ask for answers from the great gods, especially confused

Mar.04,2021

your setInterval (test.all,1000) is equivalent to

setInterval(function(){
        console.log(this)
        this.func1()
        this.func2()
        this.func3()
    },1000)

this is out of the context of test , so this points to window

.

to execute normally, upload the test context: so
setInterval (test.all.apply (test), 1000) is fine


bind object goes in
setInterval (test.all.bind (test), 1000);

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-1b348d9-e471.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-1b348d9-e471.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?