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?

有帮助吗?

解决方案

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.

其他提示

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top