Skip to content
Advertisement

Javascript, remove jQuery call

I have a file.js like this:

JavaScript

My question is (I’m not sure how jQuery works at this)

  • What is doing the last if statement?

My idea is to convert that all function in a React util like

JavaScript

And to use its methods and values, but I don’t understand what it is doing that last part that I said. Any help please.

Advertisement

Answer

What is doing the last if statement?

It is simply checking if jQuery exists in the window object since the $ alias is accessed in the following instruction. This is an example of IFEE. The code checks if window.jQuery exists, then passes it to the IFEE and catches it as $ in the parameter for that function.

I hope this answered your question.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement