According the this 'use strict'
does not support in IE version 8/9.
My question is, Is it really safe to use 'use strict' in IE 8/9 or browsers that its not patible with? Will it break my code?
According the this http://caniuse./use-strict 'use strict'
does not support in IE version 8/9.
My question is, Is it really safe to use 'use strict' in IE 8/9 or browsers that its not patible with? Will it break my code?
Share Improve this question edited Nov 18, 2013 at 2:00 Shabith asked Aug 14, 2013 at 4:57 ShabithShabith 3,0053 gold badges26 silver badges20 bronze badges 1- The caution says it all, details in the article: msdn.microsoft./en-us/library/br230269(v=vs.94).aspx – user3348703 Commented Feb 24, 2014 at 22:07
2 Answers
Reset to default 18The statement "use strict";
will should not cause problems with IE8/9 insofar as the browsers will run the code. (It was designed that way, to ensure that there are no problems with browsers that don't implement strict mode)
External source: http://ejohn/blog/ecmascript-5-strict-mode-json-and-more/
This means that you can turn strict mode on in your scripts – today – and it’ll have, at worst, no side effect in old browsers.
NOTE: as Jeremy pointed out in the ments, there are some expressions which are technically valid but will fail in IE8 (for example: var x = {}; x.break = true
will not work in IE8 even though it will work in IE9).
Yeah, it should be fine.
use
directives are meant to be backwards-patible. Browsers that don't support them will just see a String
literal that isn't referenced further. So, they'll pass over it and move on.
Though, you'll still want to be sure that you test your code both with and without it enabled.