Questions tagged [strict-mode]

According to Mozilla Developer Network, ECMAScript 5's strict mode is a way to opt in to a restricted variant of JavaScript. Strict mode isn't just a subset: it intentionally has different semantics from normal code.

According to Mozilla Developer Network, ECMAScript 5's strict mode is a way to opt in to a restricted variant of JavaScript. Strict mode isn't just a subset: it intentionally has different semantics from normal code.

93 questions
141
votes
8 answers

What is "strict mode" and how is it used?

I've been looking over the JavaScript reference on the Mozilla Developer Network, and I came across something called "strict mode". I read it over and I'm having trouble understanding what it does. Can someone briefly explain (in general) what its…
nkcmr
  • 9,732
  • 25
  • 58
  • 81
95
votes
4 answers

material-ui Drawer - findDOMNode is deprecated in StrictMode

I have a simple ReactJS app based on hooks (no classes) using StrictMode. I am using React version 16.13.1 and Material-UI version 4.9.10. In the Appbar I am using Drawer.
79
votes
3 answers

Can I disable ECMAscript strict mode for specific functions?

I don't find anything about my question here on MDC or the ECMAscript specifications. Probably somebody knows a more 'hacky' way to solve this. I'm calling "use strict" on every javascript file in my environment. All my files start like…
jAndy
  • 212,463
  • 51
  • 293
  • 348
78
votes
7 answers

Is there any way to check if strict mode is enforced?

Is there anyway to check if strict mode 'use strict' is enforced , and we want to execute different code for strict mode and other code for non-strict mode. Looking for function like isStrictMode();//boolean
Deepak Patil
  • 3,000
  • 3
  • 21
  • 21
68
votes
11 answers

Warning: findDOMNode is deprecated in StrictMode. findDOMNode was passed an instance of Transition which is inside StrictMode

I am trying to use a function as a prop inside a component and this component is a child of another component. But the function is not working.? Can I know why. This is the warning i am receiving in the console. Warning: findDOMNode is deprecated…
55
votes
2 answers

Why is delete not allowed in Javascript5 strict mode?

I'm fairly new to javascript. I noticed that apparently when operating in "use strict" mode, you can't delete objects. I'm not a huge fan of deleting things (since, in theory, scope should take care of that anyway), but I wonder what was the…
sircodesalot
  • 10,501
  • 5
  • 44
  • 78
42
votes
4 answers

Why is body.scrollTop deprecated?

It seems body.scrollTop (and body.scrollLeft) are deprecated in ES5 strict-mode. What is the reason for this, given that it still seems okay to use these properties on other DOMElements? Background Info: I have a function that tries to increase (or…
Himanshu P
  • 8,305
  • 5
  • 35
  • 45
30
votes
4 answers

Should I 'use strict' for every single javascript function I write?

Should I 'use strict' for every single javascript function I write? What is a good practice to use strict in a large AngularJS project? Using it globally can break a third party library that doesn't support it, but doing 'use strict' every single…
Won Jun Bae
  • 4,379
  • 5
  • 39
  • 48
24
votes
5 answers

Possible to enable "strict mode" in FireBug and Chrome's console?

With this page: Firebug console gives: applying the 'delete' operator to an unqualified name…
AJP
  • 21,889
  • 17
  • 76
  • 108
22
votes
1 answer

How to get caller from strict mode?

Strict and non-strict code can be mixed. But you can't use caller even if the call to it is not in strict code. Does anybody know any workaround? I tried this: (function strict(){ "use strict"; nonStrict();//ok nonStrictCaller();//error…
Quadroid
  • 805
  • 2
  • 9
  • 15
21
votes
4 answers

Getting a reference to the global object in an unknown environment in strict mode

What is the recommended way to get a handle to the global object in ES5 strict mode in an unknown host environment? ECMAScript doesn't provide a built-in way to reference the global object that I'm aware of. If it does, this is the answer I'm…
Dagg Nabbit
  • 68,162
  • 17
  • 100
  • 136
20
votes
4 answers

Why are Octal numeric literals not allowed in strict mode (and what is the workaround?)

Why are Octal numeric literals not allowed in JavaScript strict mode? What is the harm? "use strict"; var x = 010; //Uncaught SyntaxError: Octal literals are not allowed in strict mode.

Check browser console for errors

In case a…
Zameer Ansari
  • 23,672
  • 19
  • 120
  • 191
17
votes
3 answers

Two functions with the same name in JavaScript - how can this work?

As far as I know, function foo() { aaa(); } is just var foo = function(){ aaa() } in JavaScript. So adding function foo() { bbb(); } should either overwrite the foo variable, or ignore the second definition - that's not the point. The point is that…
tillda
  • 16,950
  • 16
  • 48
  • 69
17
votes
3 answers

React DnD: Avoid using findDOMNode

I don't fully understand it but apparently it isn't recommended to use findDOMNode(). I'm trying to create drag and drop component but I'm not sure how I should access refs from the component variable. This is an example of what I currently…
joshhunt
  • 4,685
  • 2
  • 31
  • 56
16
votes
4 answers

TypeError: Attempted to assign to readonly property. in Angularjs application on iOS8 Safari

Our Mobile App is getting "TypeError: Attempted to assign to readonly property." only on IOS 8 and the stack traces are not helpful and seem to be in Angular code. This might be happening because of the "use strict" on top level of Angularjs code.…
Sara Navidpour
  • 243
  • 1
  • 2
  • 8
1
2 3 4 5 6 7