Questions tagged [use-strict]

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.

100 questions
2
votes
1 answer

How does "use strict" modify the rules for "this" in Javascript?

I'm trying to understand what rule for "this" that "use strict"; modifies in the below case. After reading (http://unschooled.org/2012/03/understanding-javascript-this/) my best guess is that since the functon isStrictModeOn() is not "attached" to…
Jazzepi
  • 5,259
  • 11
  • 55
  • 81
2
votes
2 answers

"use strict" makes my CasperJS test crashing if using this

Here is the code : (function() { /*global casper:true */ "use strict"; this.run = function(casper) { // code test here }; this.run(casper); })(); casperjs test myfile.js returns : TypeError: 'undefined' is not an object…
AsTeR
  • 7,247
  • 14
  • 60
  • 99
1
vote
2 answers

How to disable "Use Strict" in Jest

I am writing some unit tests for a codebase which uses octal literals. Whenever the test is executed with npm test, a syntax error appears as follows: Legacy octal literals are not allowed in strict mode. I should stress that "use strict" does not…
1
vote
1 answer

Use strict is not working when I call my hoisted function

I have the following code "use strict"; x = 12; function myFunction() { } myFunction(); so i am using use strict at the top of my script and now I am in strict mode - so I can't have undeclared variable like x That gives me the following error in…
1
vote
1 answer

I have 'use-strict' mode in JS enabled implicitly

It turns out that I have 'use-strict' enabled and I don't know why... const isStrict = () => !this console.log( isStrict() ); This code returns me true and I'm testing it in a plain .js file, without dependencies or anything. Maybe an extension…
1
vote
1 answer

"use strict" does not work on ES6 using Visual Studio Code

In "use strict" mode, this in function should be [object Window] rather than the object that calls the function in regular mode. But when I'm trying to proof of concept, it doesn't work, I'm wondering something's wrong with the ES6 extension in…
1
vote
0 answers

I read that 'use strict' error but it doesn't tell what exactly is causing the error

Seems like there is a bad coding habit but it doesn't tell exactly where. Anybody has an experience with that? this is the code causing an error $scope.removeAllSelectedItems = function (selectedItems) { if (selectedItems.length > 0)…
dumb11
  • 129
  • 1
  • 9
1
vote
1 answer

JavaScript "use strict" inconsistently working in Chrome snippets / DevTools Sources panel

I am currently taking a Udemy course on "Advanced" Javascript concepts (https://www.udemy.com/course/javascript-advanced/), and the first lesson goes over the "use strict" command and its functionality. The course uses Chrome's Sources panel to…
longoria
  • 11
  • 3
1
vote
1 answer

Angular: "use strict" IE11

I ran into a problem in the browser IE11. The project is in Angular 2/4. Error: Multiple definitions of a property not allowed in strict mode. In file main.bundle.js
1
vote
1 answer

Javascript - Assign (not clone) a large object to a new variable to reduce its name

I want to assign a large object to a new variable to reduce its name, but I have an error : "realEstateProjectFundReuse" is read-only const realEstateProjectFundReuse = this.project.realEstateProjectMotivation.realEstateProjectFundReuse …
Mouad Ennaciri
  • 1,217
  • 3
  • 15
  • 28
1
vote
1 answer

Is it necessary to use strict when using certain es6 methods in Node.js

We are having a debate at my work, some people say when using es6 and nodejs, without babel of course, you should always add 'use strict' BECAUSE some es6 methods may not work. I can't find documentation supporting this, is it true?
Daniel Kobe
  • 9,376
  • 15
  • 62
  • 109
1
vote
1 answer

Using "using strict" as a backup for "use strong"

Is there someway to use "use strong"; and have "use strict"; used as a backup? Since it appears like Google Chrome is the only browser to support "use strong"; at the moment.
erikvold
  • 15,988
  • 11
  • 54
  • 98
1
vote
3 answers

Why is typescript complaining when a /// reference is after 'use strict'?

This question is some what related to Why is typescript failing to import a module?, which I asked yesterday. The initial setup is the same. I have a simple typescript file like this: /// 'use…
Andrew Eisenberg
  • 28,387
  • 9
  • 92
  • 148
1
vote
0 answers

make class such that configure one time & use method of that class in any file in project

All i want is to make 1 time configuration in main file(main.js) while server starts... And use method of that class multiple time in different files(conn1.js,conn2.js)... i am making a npm module which is not working while using 'use strict'. but…
Vishant dhandha
  • 495
  • 7
  • 19
1
vote
1 answer

Why is 'Use Strict' causing functions to be undefined

I have a partial that is loading two scripts. The second script calls a function in the first script... Both scripts use "use strict;" at the top. When the second script calls the function in the first script, I get an "Uncaught ReferenceError the…