O uso de unref () e ref () é muito simples, usado para cancelar e responder às funções SetTimeout e SetInterval.
O código é o seguinte:
A cópia do código é a seguinte:
var testFunction = function () {
console.log ("guoyansi");
}
var timer = setInterval (testFunction, 1000);
timer.unref (); // cancele o uso de funções Settimeout e SetInterval
timer.ref (); // restaura o uso de funções Settimeout e SetInterval
É super simples? Se você não entende, por favor, solte o JavaScript ~