7

I am currently learning JavaScript and I would like to ask if it is really necessary/advisable to do 'use strict' in all of my JavaSript functions? In line with this, will it improve the overall quality of my code?

Here are points that hinders me in using 'use strict':

  • I think it's too repetitive to do 'use strict' all the time
  • Wouldn't it just hinder my productivity? or is it just a matter of getting used to?
  • Lastly, codes I see online does not use it. Meaning, converting those codes to a code that 'use strict' will allow would probably waste a portion of my time.

Is 'use strict' still relevant?

seulgibear
  • 601
  • 1
  • 6
  • 17
  • 4
    You can also just write it once at the top of the file, and the whole file will be interpreted in strict mode. – Yourpalal Aug 23 '17 at 21:20
  • 2
    I wouldn't suggest using it in every function when you just just put it once as the first line in the file.. But yes, It will help you adhere to good practices. – Jimenemex Aug 23 '17 at 21:20
  • Thanks, didn't knew it could be written once. In addition, is it a standard that most companies use in writing their codes? – seulgibear Aug 23 '17 at 21:22
  • Also [it's implicitly active](https://stackoverflow.com/a/29285330/1048572) in new ES6 features like modules and classes. Most likely you're already using it without knowing it when writing modern code. – Bergi Aug 23 '17 at 21:23
  • 1
    @nkpg Yes, everyone's using it. Build tools take care of the repetitiveness (which is also why you don't see it everywhere online - it's an implicit standard). Profiting from the errors it throws on undesirable things will increase your productivity. – Bergi Aug 23 '17 at 21:26
  • @Bergi thanks for answering my queries. – seulgibear Aug 23 '17 at 21:30

0 Answers0