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.

112 questions
4
votes
2 answers

Changing the type of a variable in strict mode

Whilst taking a quiz on PluralSight about JavaScript, I came across this question: Assuming you've enabled strictness, can you change the type of a variable once defined? Yes, without restriction Yes, but you have to redefine the variable No The…
noggin182
  • 627
  • 4
  • 14
4
votes
1 answer

How to enable strict mode for my whole package but not for dependency?

I used to write "use strict"; as first line in my JavaScript files to enable the strict mode. Now I don't want to add this as boilerplate code to over 200 JavaScript files of my current NodeJs package. Is there any way to force strict mode for all…
Sebastian Barth
  • 4,079
  • 7
  • 40
  • 59
4
votes
1 answer

Call overloaded method from Drools: `unable to resolve method using strict-mode`

I'm newbie with java and drools and I have to build a java RESTful Web Services / rules engine. We already have Genesys Rule Authoring (GRAT) and Genesys Rule Engine (GRE) (version 8.1.2) who run drools version 5.2. We have the need to take the…
Alain Tanguay
  • 43
  • 1
  • 2
  • 5
3
votes
1 answer

Defining "eval" as a formal parameter of a Function constructor invocation. Shouldn't that throw a syntax error in strict mode code?

The specification states: It is a SyntaxError to use within strict mode code the identifiers eval or arguments as the Identifier of a FunctionDeclaration or FunctionExpression or as a formal parameter name (13.1). Attempting to dynamically…
Šime Vidas
  • 182,163
  • 62
  • 281
  • 385
3
votes
2 answers

Determine MySql mode from PHP

Is there any way to find if mysql server is in strict mode or not from PHP? I need to find out this at runtime(in installation script), so I can inform user if his system satisfy script requirements.
Ivica
  • 795
  • 2
  • 8
  • 20
3
votes
1 answer

Why is toString always running in strict mode?

I know that according to ECMAScript specification, non-strict methods will have thisArg transformed to the global object, if null or undefined was passed to them. That's the reason this code logs the window object (in browsers) instead of…
user3009344
3
votes
1 answer

How to import a library in non-strict mode in strict Angular app?

I'm trying to import jschardet in an Angular 11 project. The current version 3.0.0 does not run in strict mode (throws TypeError at runtime). I tried to reproduce this issue in a minimal example. Therefore, I generated a new Angular project and used…
maiermic
  • 4,764
  • 6
  • 38
  • 77
3
votes
0 answers

Why doesn't Strict Mode throw Syntax Error on duplicated property names?

In JavaScript, Strict Mode is supposed to throw Syntax Error if we try to define object with duplicated properties, like this: const foo = {a: 1, a: 2}; Call me crazy, but I remember it did. Today I was in shock to find out that it doesn't at least…
Robo Robok
  • 21,132
  • 17
  • 68
  • 126
3
votes
2 answers

Retrieve "self" function in the strict-mode JavaScript

I often need in a function f to retrieve a name of the method that points to f. For example. Let's say we have a getMethodName(obj, methodFunction) function that uses foreach on obj to find a property that is a link to methodFunction: obj = { …
tillda
  • 18,150
  • 16
  • 51
  • 70
3
votes
1 answer

How can [this] be undefined in strict mode?

When I run this code in Chrome, I get an Uncaught TypeError: Cannot read property 'concat' of undefined function _log() { 'use strict' [this].concat(Array.from(arguments)).forEach( function (obj) { console.log(obj) } …
Lynn
  • 423
  • 4
  • 10
3
votes
2 answers

Why does strict mode make such simple actions such different?

There is an extremely simple algorythm, which works surprisely different in two cases, depending on the presence of "use strict". Case 1: If func() declaration is within the strict mode, than console logs primitive "use strict"; // strict mode is…
Parzh from Ukraine
  • 7,999
  • 3
  • 34
  • 65
3
votes
1 answer

Dynamic parameter accessing default value

I have a PowerShell function that takes an optional parameter, validated using a ValidateSetAttribute, and based on that value it adds another dynamic parameter. However, in strict mode, when trying to access the parameter inside of the DynamicParam…
poke
  • 369,085
  • 72
  • 557
  • 602
2
votes
2 answers

Must we pay attention to JavaScript "strict mode"?

Reading about ECMAScript 5's strict mode I learn that: Certain language functions are so pervasive that performing runtime checks has considerable performance cost. A few strict mode tweaks, plus requiring that user-submitted JavaScript be…
Igor Parra
  • 10,214
  • 10
  • 69
  • 101
2
votes
1 answer

findDOMNode is deprecated

On my site (written in React) I use a calendar so that the user can select a date and time range. For this I use the react-advanced-datetimerange-picker library. Also in index.js file I use . Because of this, when working with the…
Paul
  • 53
  • 3
  • 21
2
votes
1 answer

What is difference between fragments and strict mode?

My question is apart from obvious difference, what are the main difference between fragment and strict mode?