Can you use $(function () {}); to solve the problem of global variable pollution?

can I use $(function () {}); to solve the problem of global variable pollution?

you often use (function () {}) (); to prevent global variable contamination, but can you also use $(function () {}); to do this?

Jul.23,2021

should be OK, as long as the method cannot access the variables in vitro, it can be


$(function () {}); is $(document) .ready (function () {. , while (function () {}) (); is the immediate execution function

Menu