Mode used in languages such as Javascript and Perl to be able to code with a restricted version of those languages.
Questions tagged [strict]
490 questions
321
votes
5 answers
How do I break out of a loop in Perl?
I'm trying to use a break statement in a for loop, but since I'm also using strict subs in my Perl code, I'm getting an error saying:
Bareword "break" not allowed while
"strict subs" in use at ./final.pl
line 154.
Is there a workaround for…

Zain Rizvi
- 23,586
- 22
- 91
- 133
215
votes
1 answer
Not recommended to use "use strict" in ES6?
I'm not familiar with ECMAScript 6 yet. I've just cloned the React Starter Kit repo, which uses ES6 for application code. I was surprised to see that the linter is configured to forbid occurences of the use strict directive, which I thought was…

Midiparse
- 4,701
- 7
- 28
- 48
174
votes
7 answers
PHP 5 disable strict standards error
I need to setup my PHP script at the top to disable error reporting for strict standards.
Can anybody help ?

Manny Calavera
- 6,815
- 20
- 60
- 85
101
votes
4 answers
Why is JSHINT complaining that this is a strict violation?
I think this may be a duplicate of Strict Violation using this keyword and revealing module pattern
I have this code:
function gotoPage(s){
if(s<=this.d&&s>0){this.g=s; this.page((s-1)*this.p.size);}
}
function pageChange(event, sorter) {
…

Cheeso
- 189,189
- 101
- 473
- 713
82
votes
6 answers
Error message "Strict standards: Only variables should be passed by reference"
$el = array_shift($instance->find(..))
The above code somehow reports the strict standards warning, but this will not:
function get_arr(){
return array(1, 2);
}
$el = array_shift(get_arr());
So when will it report the warning anyway?

user198729
- 61,774
- 108
- 250
- 348
60
votes
6 answers
Does python have a "use strict;" and "use warnings;" like in perl?
I am learning perl and python... at the same time, not my by design but it has to be done.
Question:
In a perl script I use(see below) at the head of my txt.
#!/usr/bin/env perl
use strict;
use warnings;
Is there something I should be doing on…

jon_shep
- 1,363
- 3
- 15
- 24
53
votes
3 answers
Strict Violation using this keyword and revealing module pattern
Having trouble getting the following to pass jslint/jshint
/*jshint strict: true */
var myModule = (function() {
"use strict";
var privVar = true,
pubVar = false;
function privFn() {
return this.test; // -> Strict…

Matty F
- 3,763
- 4
- 30
- 48
45
votes
2 answers
the seq function and strictness
I have been wondering about this a lot, but I haven't been able to find anything about it.
When using the seq function, how does it then really work? Everywhere, it is just explained saying that seq a b evaluates a, discards the result and returns…

Undreren
- 2,811
- 1
- 22
- 34
42
votes
4 answers
In ECMAScript5, what's the scope of "use strict"?
What scope does the strict mode pragma have in ECMAScript5?
"use strict";
I'd like to do this (mainly because JSLint doesn't complain about it):
"use strict";
(function () {
// my stuff here...
}());
But I'm not sure if that would break other…

Stephen Sorensen
- 11,455
- 13
- 33
- 46
40
votes
3 answers
JavaScript: Can ECMAScript 5's Strict Mode ("use strict") be enabled using single quotes ('use strict')?
JavaScript doesn't care if your Strings are double-quoted "double" or single-quoted 'single'.
Every example of ECMAScript 5's strict mode has it enabled by "use strict" in double-quotes. Can I do the following (single-quotes):
alert(function(){
…

Rudiger
- 411
- 4
- 5
34
votes
4 answers
Which (javascript) environments support ECMAscript 5 strict mode? (aka "use strict")
ECMAScript 5 is in its final draft as I write this; It is due to include a strict mode which will prevent you from assigning to the global object, using eval, and other restrictions. (John Resig's Article is a good introduction.)
This magical…

Sean McMillan
- 10,058
- 6
- 55
- 65
31
votes
2 answers
GCC options for strictest C code?
What GCC options should be set to have GCC as strict as possible? (and I do mean as strict as possible) I'm writing in C89 and want my code to be ANSI/ISO compliant.
user1149305
29
votes
3 answers
Would this enable "use strict" globally?
Similar, but not the same as, How to enable ECMAScript "use strict" globally?
I have bought JavaScript Patterns and it recommends enabling use strict. Adding it to the two dozen javascript files would be a bit of a chore, so enabling it globally…

graham.reeds
- 16,230
- 17
- 74
- 137
29
votes
7 answers
Get current function name in strict mode
I need the current function name as a string to log to our log facility. But arguments.callee.name only works in loose mode. How to get the function name under "use strict"?

exebook
- 32,014
- 33
- 141
- 226
28
votes
4 answers
Can comments come before `use strict;`?
I've seen a few places around the internet passively stating 'use strict;' must come on the first line of the functional scope for which you want the behavioral directive to apply.
However, in my experience, it doesn't matter if there are comments…

Qix - MONICA WAS MISTREATED
- 14,451
- 16
- 82
- 145