FE/JS
즉시 실행 함수
Chars4785
2022. 6. 21. 18:10
useQuery 뒤지다가 나온 코드인데 어려워서 찾아본다.
function myFun(a,b){
console.log(a,b)
return a + b
}
const bb = (0,myFun)(1,2)
console.log(bb)
제일 왼쪽 함수를 바로 실해하기 위함이다.
참고
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comma_Operator
Calling function with window scope explanation (0, function(){})()
I am curious as to why this works: var c = { d: function myFunc() { console.log(this === window); } }; var a = { b: function() { console.log(this === a); (0,...
stackoverflow.com