I'm getting this error in safari console when I try to do anything from a breakpoint. Bug report here: https://bugs.webkit.org/show_bug.cgi?id=83267
Does anyone have a workaround? For reasons that I am assuming are related to this javascript has ceased to run on my site in safari.
edit: the bug report also contains repro steps.
another edit: I'm not using a "with" statement. This is a bug from the safari console.
No, you can't disable strict mode per function. Notice how we can define function outside of strict code and then pass it into the function that's strict. You can do something similar in your example — have an object with "sloppy" functions, then pass that object to that strict immediately invoked function.
Strict mode is declared by adding "use strict"; to the beginning of a script or a function.
This proves that this here refers to the global object, which is the window object in our case. Note that, if strict mode is enabled for any function then the value of this will be undefined because in strict mode global object refers to undefined in place of the window object.
Using Strict mode for a function: Likewise, to invoke strict mode for a function, put the exact statement “use strict”; (or 'use strict';) in the function's body before any other statements. Examples of using Strict mode: Example: In normal JavaScript, mistyping a variable name creates a new global variable.
The with(obj) {}
statement is deprecated, and as such, is not valid in strict mode.
To solve this, either disable strict mode, or stop using with statements!
Strict mode in ECMAScript 5 bans eg. with
statement. You have two choices:
"strict mode";
line from the file / function), orwith
statements - they are harmful and totally unreadable.More on strict mode from John Resig: ECMAScript 5 Strict Mode, JSON, and More.
You can read in the article, that strict mode:
delete
variable (like in delete foo;
),eval
,caller
and callee
),with
statements,If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With