Question

I'd appreciate your lessons learnt through experience on when to and when NOT to, "use strict" in Javascript.

IMHO, "use strict" is good in server-side javascript code but NOT client-side, because not all (even modern) browsers support this feature. Correct?

Était-ce utile?

La solution

Read this john resig on strict mode

"use strict"; is as important in client side javascript programming as in server's.

If it is not supported by a browser it would do no harm as it is just a string plus a semicolon .. which would do nothing if not recognized correctly by an interpreter.

With "use strict"; mode .. if your program runs correctly even in one of the modern browsers like chrome then you now know that your program does not have any silly errors. After that you are good to go on any other possible browser because as I said it would do no harm if not interpreted correctly.

Autres conseils

yeah, thats right. But some browser not supported.

Actually, a lot of modern browser supported use-strict.

        Internet Explorer = v10,v11
        Firefox           = v4.0 +
                **Webkit** 
        Chrome            = v13.0 +
        Opera             = v11.6 +
        Safari            = v6.0 + 

check it please : http://caniuse.com/use-strict

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top