FYI, "at the top of" means "inside", not "on top". That's why I was originally confused. // Non-strict code... (function(){ "use strict"; // Define your...
1685
Jakob Kruse
thekrucible
Dec 14, 2010 8:06 am
In your second example, "use strict"; is neither at the top of a file or at the top of a function, thus it has no effect. /Jakob _____ From: AJ ONeal...
1686
Douglas Crockford
douglascrock...
Dec 14, 2010 10:56 pm
JSLint is now recommending the function form of strict pragma and not the file form. So "use strict"; ... is out, and (function () { ... }()); is in. See also...
1687
abyssoft@...
abyssoft...
Dec 14, 2010 11:17 pm
This change is a paradigm level change. This causes all of my scripts to now complain. While after having read the article I believe this be the best practice;...
1688
Douglas Crockford
douglascrock...
Dec 14, 2010 11:26 pm
... Your sadly pathetic bleatings are harshing my mellow....
1689
Douglas Crockford
douglascrock...
Dec 21, 2010 9:42 pm
... Thanks. Please try it now. In the future, please try to refine the problem text in bug reports. It is greatly appreciated if you try to make the example...
1690
abyssoft@...
abyssoft...
Dec 21, 2010 11:23 pm
Works now. Thank you....
1691
kipenzam
Dec 28, 2010 3:02 pm
Hello, I have linted my program, and got this error : Problem at line 6 character 45: Insecure '.'. var reg = type === 'html' ? /<!--.*?-->/g:...
1692
Douglas Crockford
douglascrock...
Dec 28, 2010 5:43 pm
... Turn off the secure regexp option, or enumerate the set of characters that . should match....
1693
biggeleben
Dec 29, 2010 11:05 pm
Hi, after hours of figuring out why my code fails JSLINT's validation (edition 2010-12-23), I decided to post here. The original code uses some jQuery chains,...
1694
biggeleben
Dec 29, 2010 11:14 pm
Please use the "fixed width font" option to read my previous post properly. Otherwise the indentation gets lost....
1695
kipenzam
Dec 30, 2010 1:27 am
Hello, I coded like this: (function () { Kip.shell2 = function (stream, reg, prefix, suffix) { return stream ? stream.replace(reg, function ($1) { return...
1696
Douglas Crockford
douglascrock...
Dec 30, 2010 2:18 am
... JSLint doesn't like silly indentation schemes. Turn off the Strict Whitespace option....
1697
Douglas Crockford
douglascrock...
Dec 30, 2010 2:21 am
... That's not the result I see. What aren't you telling us?...
1698
duncan.cross@...
duncan.cross...
Dec 30, 2010 2:58 am
If I have a switch case that ends with an if-block, and all of the if-block's child statements end with either 'break39; or 'return39;, like case 0 here: function...
1699
Douglas Crockford
douglascrock...
Dec 30, 2010 4:06 am
... JSLint does not currently do the flow analysis to determine that every path through a case returns. So move the break after case 1 to just before case 1. ...
1700
biggeleben
Dec 30, 2010 1:05 pm
... Ok, that's a pragmatic solution :) However, the "Strict Whitespace" option is very helpful. Please think of tons of code and a bunch of developers of which...
1701
Alex
trueman_boy
Dec 30, 2010 9:02 pm
Hey guys, I've had this silly bug with setTimeout today where I put this line of code: setTimeout(getDatesOfWeek(), 1000); So I reference the function and...
1702
Mark Volkmann
mark_volkmann
Dec 30, 2010 9:06 pm
... Try this: setTimeout(getDatesOfWeek, 1000); Not that this passes the function getDatesOfWeek to setTimeout rather than passing the result of invoking it. ...
1703
Alex
trueman_boy
Dec 30, 2010 10:13 pm
Oops, I forgot to mention that was after I found the solution which is to remove the (). But the question still stand as for how come it's valid and doesn't...
1704
Joshua Bell
inexorabletash
Dec 30, 2010 10:44 pm
... Consider: function make_callback(arg) { console.log("making a new callback function..."); var cb = function() { console.log("callback called: ", 123); }; ...
1705
Erik Eckhardt
vorpalmage
Dec 30, 2010 11:08 pm
It's not an error because setTimeout expects a function as the first parameter. However, if the first parameter is of type string, presumably it wraps it in an...
1706
Alex
trueman_boy
Dec 31, 2010 1:42 am
Thanks for the thorough explanation, it seems more logical now. But I still can't get my head around it... Here's my test code: function getDatesOfWeek() { var...
1707
Mark Volkmann
mark_volkmann
Dec 31, 2010 11:41 am
I looks like you want to update the seconds every 1000 ms. I think you want this: function updateSeconds() { var currentDate = new Date(); ...
1708
Cheney, Edward A SSG ...
sandyhead25
Dec 31, 2010 2:18 pm
Classification: UNCLASSIFIED ... Instead of altering some validation software to conform to user behavior perhaps you should alter your process to mitigate...
1709
Felix E. Klee
feklee
Dec 31, 2010 5:33 pm
If I write code such as the following, then JSLint complains that "f" is not defined. var sendToServer; function callback(moreToDo) { // do something ... if...
1710
Erik Eckhardt
vorpalmage
Dec 31, 2010 6:21 pm
Instead of passing in a flag and then hardcoding the function, pass in a function: function callback(morefn) { ___// do something ... ___if (typeof(morefn) ===...
1711
Felix E. Klee
feklee
Dec 31, 2010 8:12 pm
... Are you sure this makes sense? The second last line will always evaluate to: sendToServer('xyz39;, f); And I don't see how this solves the issue I raised: ...
1712
Rob Richardson
erobrich@...
Dec 31, 2010 8:49 pm
Felix, The primary concern is you're trying to use a function earlier in your code file than when it is defined. If you put var f = function () {... before ...
1713
Felix E. Klee
feklee
Jan 1, 2011 10:59 am
On Fri, Dec 31, 2010 at 9:49 PM, Rob Richardson <erobrich@...> ... No, the opposite is true. See the second example in my original post. That works...