Js's question about self-executing functions.

var arr;
console.log (arr)
(function (a) {console.log (a)})
(arr)

clipboard.png

Dec.21,2021

var arr;
console.log (arr);
(function (a) {console.log (a);}) (arr)
not added; all are cults


because you are ambiguous in writing that way, your code will be automatically formatted in ESLint as:

var arr
console.log(arr)(function (a) {
  console.log(a)
})(arr)

learn ESLint and you won't have such a problem. You can change it to this:

var arr
console.log(arr)
;(function (a) { console.log( a ) })( arr )

the teacher said, (the semicolon should be preceded by the line at the beginning of [{]

Menu