console
function debounceFn (fn,wait) {
let timer = null
return function(...args) {
this.a = 15
clearTimeout(timer);
timer = setTimeout( () => {
fn(args)
},wait)
}
}
function init(){
this.a = 12
function test(){
console.log(this.a)
}
const dom = document.getElementById('test')
var testDebounce = debounceFn(test,500)
dom.addEventListener('input',testDebounce)
}
init()
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=, initial-scale=">
<meta http-equiv="X-UA-Compatible" content="">
<title></title>
<script>
</script>
</head>
<body>
<input type="text" id="test">
</body>
</html>