Archi Patel
Archi Patel

Reputation: 173

"myFunction" is defined but never used & Missing "use strict" statement clash

I was using JavaScript Code in my index.html page. and then I thought to shift all my JavaScript code to .js file. so when I did all the copy-paste thing and moved all my code to .js file. I started getting error in Dreamweaver

error was: Missing "use strict" statement

and so I wrote "use strict"; on top of my .js file

now I started getting error : Use the function form of "use strict"

so I tried (function () { "use strict"; //rest of my code })();

now I have solved all the error related to "use strict";

but now I have another error : "myFunction" is defined but never used.

and to solve that I'm using /*exported myFunction*/

but that is not working can anyone guide what should I do to remove 2 error I'm getting ?

  1. "myFunction" is defined but never used
  2. Missing "use strict" statement

should I use "use strict"; and /*exported myFunction*/ inside each function of my code onebyone ?

Upvotes: 2

Views: 3698

Answers (1)

Scott Marcus
Scott Marcus

Reputation: 65806

Neither of those are errors. They are warnings that Dreamweaver is alerting you to.

  1. "use strict" is never required, but can be a good best-practice to use in many cases because it can alert you to problems in your code that will silently fail without it.
  2. The fact that you have a function, but never call it is also not an error. It's just Dreamweaver telling you about code that seems unnecessary because you are not using that code.

Upvotes: 3

Related Questions