Skip to search.

Breaking News Visit Yahoo! News for the latest.

×Close this window

jslint_com · This group has moved to Google Plus.

The Yahoo! Groups Product Blog

Check it out!

Group Information

  • Members: 584
  • Category: JavaScript
  • Founded: Mar 7, 2008
  • Language: English
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Real people. Real stories. See how Yahoo! Groups impacts members worldwide.

Messages

Advanced
Messages Help
Messages 3099 - 3129 of 3202   Oldest  |  < Older  |  Newer >  |  Newest
Messages: Show Message Summaries Sort by Date ^  
#3099 From: "george_weilenmann" <abyssoft@...>
Date: Fri Jan 18, 2013 11:37 pm
Subject: Re: [jslint] regex parsing - [^]
george_weile...
Send Email Send Email
 
Can you point me to the specific link, page, paragraph etc. where this is
spec'd, I looked on mozilla and could not find this "suggestion". I wanted to
take a look at it in a RegExp validator; and it's not a valid RegExp.

<.+>[^]<.+>

ends up being analyzed as follows

<
any character, one or more repetitions
>
(X) unmatched bracket in character class
Beginning of line or string
]
<
any character, one or more repetitions
>


--- In jslint_com@yahoogroups.com, Ben White  wrote:
>
> If you read the documentation on mozilla.org you will find [^] as their
> suggested "any character" expression
>
> Ben
> On Jan 18, 2013 4:28 AM, "Luke Page"  wrote:
>
> > **
> >
> >
> > Hi,
> >
> > My colleague was linting this and getting an error
> >
> > var a = /<.+>[^]<.+>/;
> >
> > Unescaped '^'.
> >
> > He argued that [^] was a valid succinct way of saying "any character"
> > rather than [.\n\r]* or [\s\S]*
> >
> > What do you think?
> >
> > Regards,
> >
> > Luke
> >
> > [Non-text portions of this message have been removed]
> >
> >
> >
>
>
> [Non-text portions of this message have been removed]
>

#3100 From: Keradus <keradus@...>
Date: Sat Jan 19, 2013 1:06 am
Subject: Re: [jslint] regex parsing - [^]
keradmaster
Send Email Send Email
 
2013/1/19 george_weilenmann <abyssoft@...>
> Can you point me to the specific link, page, paragraph etc. where this is
> spec'd, I looked on mozilla and could not find this "suggestion".

https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Reg\
Exp
"The character set [^] can be used to match any character including newlines."

--
keradus

#3101 From: "george_weilenmann" <abyssoft@...>
Date: Sat Jan 19, 2013 1:54 am
Subject: Re: [jslint] regex parsing - [^]
george_weile...
Send Email Send Email
 
Thankyou that did not pop out at me when I looked through that document earlier.
I would say avoid that pattern as it is not valid RegExp.

I think the way they listed the information lead to erroneous understanding. [^]
in that statement was use to symbolically represent the RegExp symbol . ; why
they chose to confuse the issue is beyond me. The segment right below that when
taken in context with the above helps to make this a little clearer but not
much.


--- In jslint_com@yahoogroups.com, Keradus  wrote:
>
> 2013/1/19 george_weilenmann
> > Can you point me to the specific link, page, paragraph etc. where this is
> > spec'd, I looked on mozilla and could not find this "suggestion".
>
>
https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Reg\
Exp
> "The character set [^] can be used to match any character including newlines."
>
> --
> keradus
>

#3102 From: "george_weilenmann" <abyssoft@...>
Date: Sat Jan 19, 2013 2:01 am
Subject: Re: [jslint] regex parsing - [^]
george_weile...
Send Email Send Email
 
Did a little digging  [^]  compiles to  not null/empty it is a side effect
resulting from the spec for RegExp as performed in JavaScript but does not apply
to other implementations of RegExp.

Given that this is unique to JavaScript I'd say that JSLint is in the right as
it is confusing.


--- In jslint_com@yahoogroups.com, Keradus  wrote:
>
> 2013/1/19 george_weilenmann
> > Can you point me to the specific link, page, paragraph etc. where this is
> > spec'd, I looked on mozilla and could not find this "suggestion".
>
>
https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Reg\
Exp
> "The character set [^] can be used to match any character including newlines."
>
> --
> keradus
>

#3103 From: "Felix E. Klee" <felix.klee@...>
Date: Sat Jan 19, 2013 12:47 pm
Subject: Re: [jslint] regex parsing - [^]
feklee
Send Email Send Email
 
On Sat, Jan 19, 2013 at 3:01 AM, george_weilenmann <abyssoft@...>
wrote:
> Given that this is unique to JavaScript I'd say that JSLint is in the
> right as it is confusing.

So, which regular expression syntax should JSLint enforce? POSIX? Is
that even compatible with the implementation in JavaScript?

Given that there are many dialects of regular expressions and not one
single authoratitive standard, in my opinion, JSLint should enforce:

Regular expressions as defined by ECMAScript. :-)

(minus dangerous constructs)

#3104 From: "douglascrockford" <douglas@...>
Date: Sat Jan 19, 2013 1:20 pm
Subject: Re: [jslint] regex parsing - [^]
douglascrock...
Send Email Send Email
 
--- In jslint_com@yahoogroups.com, "Felix E. Klee"  wrote:
>
> On Sat, Jan 19, 2013 at 3:01 AM, george_weilenmann
> wrote:
> > Given that this is unique to JavaScript I'd say that JSLint is in the
> > right as it is confusing.
>
> So, which regular expression syntax should JSLint enforce? POSIX? Is
> that even compatible with the implementation in JavaScript?
>
> Given that there are many dialects of regular expressions and not one
> single authoratitive standard, in my opinion, JSLint should enforce:
>
> Regular expressions as defined by ECMAScript. :-)


One of the design principles behind JSLint is that if a feature is problematic,
and if it can be completely replaced with another feature that is less
problematic, then the more problematic feature should not be allowed. In making
that determination, the following are irrelevant: It is permitted by a standard.
It is sometimes useful. It is totally awesome. It is popular.

#3105 From: John Hawkinson <jhawk@...>
Date: Sat Jan 19, 2013 1:35 pm
Subject: Re: [jslint] regex parsing - [^]
john.hawkinson
Send Email Send Email
 
douglascrockford <douglas@...> wrote on Sat, 19 Jan 2013
at 13:20:21 -0000 in <kde6il+8gnb@eGroups.com>:

> One of the design principles behind JSLint is that if a feature is
> problematic, and if it can be completely replaced with another
> feature that is less problematic, then the more problematic feature
> should not be allowed.

It would really help if the documentation explained why [^] was
excluded.

--jhawk@...
   John Hawkinson

#3106 From: "george_weilenmann" <abyssoft@...>
Date: Sat Jan 19, 2013 10:27 pm
Subject: Re: regex parsing - [^]
george_weile...
Send Email Send Email
 
from http://www.regular-expressions.info/javascript.html

JavaScript implements Perl-style regular expressions. However, it lacks quite a
number of advanced features available in Perl and other modern regular
expression flavors:

No \A or \Z anchors to match the start or end of the string. Use a caret or
dollar instead.
Lookbehind is not supported at all. Lookahead is fully supported.
No atomic grouping or possessive quantifiers.
No Unicode support, except for matching single characters with \uFFFF.
(Note form me on this: only the oldest implementations suffer this limitation
today)
No named capturing groups. Use numbered capturing groups instead.
No mode modifiers to set matching options within the regular expression.
No conditionals.
No regular expression comments. Describe your regular expression with JavaScript
// comments instead, outside the regular expression str

[^] is confusing and definitely should be avoided.

--- In jslint_com@yahoogroups.com, "Felix E. Klee"  wrote:
>
> On Sat, Jan 19, 2013 at 3:01 AM, george_weilenmann
> wrote:
> > Given that this is unique to JavaScript I'd say that JSLint is in the
> > right as it is confusing.
>
> So, which regular expression syntax should JSLint enforce? POSIX? Is
> that even compatible with the implementation in JavaScript?
>
> Given that there are many dialects of regular expressions and not one
> single authoratitive standard, in my opinion, JSLint should enforce:
>
> Regular expressions as defined by ECMAScript. :-)
>
> (minus dangerous constructs)
>

#3108 From: "firstbakingbook" <craft.brian@...>
Date: Tue Jan 29, 2013 6:08 pm
Subject: alternatives to eval for user-supplied functions
firstbakingbook
Send Email Send Email
 
I need to support user-supplied math functions. Are there any good alternatives
to using eval, or, more likely, the Function constructor?

I could write js code to evaluate js expression parse trees, though I suspect
the performance wouldn't be acceptable.

It looks like ADsafe is a bit like this (running 3rd party code safely), but I
don't really understand ADsafe usage. Are you expected to run jslint on a
server, before serving the js to the browser? If so, that doesn't help. I could
run jslint in the browser, but then wouldn't I still need to eval the code if it
passed? In that case I can use something simpler and much more restrictive than
jslint.

#3109 From: "andrew_wh" <aawhitaker@...>
Date: Tue Jan 29, 2013 6:22 pm
Subject: "Unexpected use of typeof" warning discrepancy
andrew_wh
Send Email Send Email
 
I understand why the following code generates the warning "Unexpected 'typeof'.
Use '===' to compare directly with undefined"

var foo;

if (typeof foo === 'undefined') {
     alert('foo undefined');
}

JSLint wants me to write this instead:

var foo;

if (foo === undefined) {
     alert('foo undefined');
}

Which is all well and good.

However I noticed that I can get around the error by simply switching the
operands in the typeof expression:

var foo;

if ('undefined' === typeof foo) {
     alert('foo undefined');
}

Is this by design? Am I missing something silly and fundamental here? Or is it a
bug in JSLint?

#3110 From: "douglascrockford" <douglas@...>
Date: Tue Jan 29, 2013 6:35 pm
Subject: Re: "Unexpected use of typeof" warning discrepancy
douglascrock...
Send Email Send Email
 
--- In jslint_com@yahoogroups.com, "andrew_wh"  wrote:
>
> I understand why the following code generates the warning "Unexpected
'typeof'. Use '===' to compare directly with undefined"
>
> var foo;
>
> if (typeof foo === 'undefined') {
>     alert('foo undefined');
> }
>
> JSLint wants me to write this instead:
>
> var foo;
>
> if (foo === undefined) {
>     alert('foo undefined');
> }
>
> Which is all well and good.
>
> However I noticed that I can get around the error by simply switching the
operands in the typeof expression:
>
> var foo;
>
> if ('undefined' === typeof foo) {
>     alert('foo undefined');
> }
>
> Is this by design? Am I missing something silly and fundamental here? Or is it
a bug in JSLint?


Thanks. Please try it now.

#3111 From: "andrew_wh" <aawhitaker@...>
Date: Tue Jan 29, 2013 8:28 pm
Subject: Re: "Unexpected use of typeof" warning discrepancy
andrew_wh
Send Email Send Email
 
Looks like it's been fixed. Thanks for the quick turnaround!

--- In jslint_com@yahoogroups.com, "douglascrockford"  wrote:
>
> --- In jslint_com@yahoogroups.com, "andrew_wh"  wrote:
> >
> > I understand why the following code generates the warning "Unexpected
'typeof'. Use '===' to compare directly with undefined"
> >
> > var foo;
> >
> > if (typeof foo === 'undefined') {
> >     alert('foo undefined');
> > }
> >
> > JSLint wants me to write this instead:
> >
> > var foo;
> >
> > if (foo === undefined) {
> >     alert('foo undefined');
> > }
> >
> > Which is all well and good.
> >
> > However I noticed that I can get around the error by simply switching the
operands in the typeof expression:
> >
> > var foo;
> >
> > if ('undefined' === typeof foo) {
> >     alert('foo undefined');
> > }
> >
> > Is this by design? Am I missing something silly and fundamental here? Or is
it a bug in JSLint?
>
>
> Thanks. Please try it now.
>

#3112 From: "paperlampshade" <beefo@...>
Date: Thu Jan 31, 2013 10:56 pm
Subject: Switch Case Style
paperlampshade
Send Email Send Email
 
Hi,
I have a question about Switch Case style as verified in jslint.A switch
case written as below (case statement starting on the line after the
switch statement) will give many errors regarding the expected position
from line "case 1:" to line "output = "";".
var test = function (input) {    'use strict';    var output;    switch
(input) {        case 1:            output = "a";            break;
case 2:            output = "b";            break;        case 3:
output = "c";            break;        default:            output = "";
}    return output;};
However when the same statement is written with the "case 1:"  statement
beginning one space after the  switch "{" and the  closing "}" one space
from the "output = "";" line, there is no errors found.Example below:
var test = function (input) {    'use strict';    var output;    switch
(input) { case 1:            output = "a";            break;        case
2:            output = "b";            break;        case 3:
output = "c";            break;        default:            output = "";
}    return output;};
Why is it important to have switch case syntax as in the second example?
Thanks very much!
Steve Hansen


[Non-text portions of this message have been removed]

#3113 From: "benquarmby" <ben.quarmby@...>
Date: Fri Feb 1, 2013 9:15 pm
Subject: Re: Switch Case Style
benquarmby
Send Email Send Email
 
Hi Steve,

I think I know what you're talking about, but the whitespace didn't come through
properly in your examples. You may wan to retype your example with tilde (~) for
spaces and ensure the line breaks stick.


Cheers
Ben

--- In jslint_com@yahoogroups.com, "paperlampshade"  wrote:
>
> Hi,
> I have a question about Switch Case style as verified in jslint.A switch
> case written as below (case statement starting on the line after the
> switch statement) will give many errors regarding the expected position
> from line "case 1:" to line "output = "";".
> var test = function (input) {    'use strict';    var output;    switch
> (input) {        case 1:            output = "a";            break;
> case 2:            output = "b";            break;        case 3:
> output = "c";            break;        default:            output = "";
> }    return output;};
> However when the same statement is written with the "case 1:"  statement
> beginning one space after the  switch "{" and the  closing "}" one space
> from the "output = "";" line, there is no errors found.Example below:
> var test = function (input) {    'use strict';    var output;    switch
> (input) { case 1:            output = "a";            break;        case
> 2:            output = "b";            break;        case 3:
> output = "c";            break;        default:            output = "";
> }    return output;};
> Why is it important to have switch case syntax as in the second example?
> Thanks very much!
> Steve Hansen
>
>
> [Non-text portions of this message have been removed]
>

#3114 From: "paperlampshade" <beefo@...>
Date: Sat Feb 2, 2013 3:33 pm
Subject: Re: Switch Case Style
paperlampshade
Send Email Send Email
 
Hi Ben,

Oh shoot, sorry about that. Hopefully this will come through better:

I have a question about Switch Case style as verified in jslint.

A switch case written as below (case statement starting on the line after the
switch statement) will give many errors regarding the expected position from
line "case 1:" to line "output = "";".

var test = function (input) {
~~~~'use strict';
~~~~var output;
~~~~switch (input) {
~~~~~~~~case 1:
~~~~~~~~~~~~output = "a";
~~~~~~~~~~~~break;
~~~~~~~~case 2:
~~~~~~~~~~~~output = "b";
~~~~~~~~~~~~break;
~~~~~~~~case 3:
~~~~~~~~~~~~output = "c";
~~~~~~~~~~~~break;
~~~~~~~~default:
~~~~~~~~~~~~output = "";
~~~~}
~~~~return output;
};

However when the same statement is written with the "case 1:" statement
beginning one space after the switch "{" and the closing "}" one space from the
"output = "";" line, there is no errors found.Example below:

var test = function (input) {
~~~~'use strict';
~~~~var output;
~~~~switch (input) { case 1:
~~~~~~~~~~~~output = "a";
~~~~~~~~~~~~break;
~~~~~~~~case 2:
~~~~~~~~~~~~output = "b";
~~~~~~~~~~~~break;
~~~~~~~~case 3:
~~~~~~~~~~~~output = "c";
~~~~~~~~~~~~break;
~~~~~~~~default:
~~~~~~~~~~~~output = ""; }
~~~~return output;
};

Why is it important to have switch case syntax as in the second example?

Thanks very much!

Steve Hansen

--- In jslint_com@yahoogroups.com, "benquarmby"  wrote:
>
> Hi Steve,
>
> I think I know what you're talking about, but the whitespace didn't come
through properly in your examples. You may wan to retype your example with tilde
(~) for spaces and ensure the line breaks stick.
>
>
> Cheers
> Ben
>
> --- In jslint_com@yahoogroups.com, "paperlampshade"  wrote:
> >
> > Hi,
> > I have a question about Switch Case style as verified in jslint.A switch
> > case written as below (case statement starting on the line after the
> > switch statement) will give many errors regarding the expected position
> > from line "case 1:" to line "output = "";".
> > var test = function (input) {    'use strict';    var output;    switch
> > (input) {        case 1:            output = "a";            break;
> > case 2:            output = "b";            break;        case 3:
> > output = "c";            break;        default:            output = "";
> > }    return output;};
> > However when the same statement is written with the "case 1:"  statement
> > beginning one space after the  switch "{" and the  closing "}" one space
> > from the "output = "";" line, there is no errors found.Example below:
> > var test = function (input) {    'use strict';    var output;    switch
> > (input) { case 1:            output = "a";            break;        case
> > 2:            output = "b";            break;        case 3:
> > output = "c";            break;        default:            output = "";
> > }    return output;};
> > Why is it important to have switch case syntax as in the second example?
> > Thanks very much!
> > Steve Hansen
> >
> >
> > [Non-text portions of this message have been removed]
> >
>

#3115 From: "Felix E. Klee" <felix.klee@...>
Date: Sat Feb 2, 2013 4:35 pm
Subject: Re: [jslint] Re: Switch Case Style
feklee
Send Email Send Email
 
On Sat, Feb 2, 2013 at 4:33 PM, paperlampshade <beefo@...>
wrote:
> ~~~~switch (input) { case 1:
>
> [...]
>
> Why is it important to have switch case syntax as in the second example?

Looks strange. The following formatting is IMHO easy to read and it
is accepted by JSLint:

     var test = function (input) {
         'use strict';
         var output;
         switch (input) {
         case 1:
             output = "a";
             break;
         case 2:
             output = "b";
             break;
         case 3:
             output = "c";
             break;
         default:
             output = "";
         }
         return output;
     };

BTW, just post emails in plain-text and no need to insert these ugly
`~`.

#3116 From: "douglascrockford" <douglas@...>
Date: Sat Feb 2, 2013 6:03 pm
Subject: Re: Switch Case Style
douglascrock...
Send Email Send Email
 
--- In jslint_com@yahoogroups.com, "paperlampshade"  wrote:
>
> Hi,
> I have a question about Switch Case style as verified in jslint.A switch
> case written as below (case statement starting on the line after the
> switch statement) will give many errors regarding the expected position
> from line "case 1:" to line "output = "";".
> var test = function (input) {    'use strict';    var output;    switch
> (input) {        case 1:            output = "a";            break;
> case 2:            output = "b";            break;        case 3:
> output = "c";            break;        default:            output = "";
> }    return output;};
> However when the same statement is written with the "case 1:"  statement
> beginning one space after the  switch "{" and the  closing "}" one space
> from the "output = "";" line, there is no errors found.Example below:
> var test = function (input) {    'use strict';    var output;    switch
> (input) { case 1:            output = "a";            break;        case
> 2:            output = "b";            break;        case 3:
> output = "c";            break;        default:            output = "";
> }    return output;};
> Why is it important to have switch case syntax as in the second example?


Thanks. Please try it now.

#3117 From: "paperlampshade" <beefo@...>
Date: Tue Feb 5, 2013 3:36 am
Subject: Re: Switch Case Style
paperlampshade
Send Email Send Email
 
Works great! Thanks very much.

--- In jslint_com@yahoogroups.com, "douglascrockford"  wrote:
>
> --- In jslint_com@yahoogroups.com, "paperlampshade"  wrote:
> >
> > Hi,
> > I have a question about Switch Case style as verified in jslint.A switch
> > case written as below (case statement starting on the line after the
> > switch statement) will give many errors regarding the expected position
> > from line "case 1:" to line "output = "";".
> > var test = function (input) {    'use strict';    var output;    switch
> > (input) {        case 1:            output = "a";            break;
> > case 2:            output = "b";            break;        case 3:
> > output = "c";            break;        default:            output = "";
> > }    return output;};
> > However when the same statement is written with the "case 1:"  statement
> > beginning one space after the  switch "{" and the  closing "}" one space
> > from the "output = "";" line, there is no errors found.Example below:
> > var test = function (input) {    'use strict';    var output;    switch
> > (input) { case 1:            output = "a";            break;        case
> > 2:            output = "b";            break;        case 3:
> > output = "c";            break;        default:            output = "";
> > }    return output;};
> > Why is it important to have switch case syntax as in the second example?
>
>
> Thanks. Please try it now.
>

#3118 From: "Felix E. Klee" <felix.klee@...>
Date: Tue Feb 5, 2013 5:14 pm
Subject: Just got confused with the `?` operator
feklee
Send Email Send Email
 
Well, today I'm not in good shape, and I expected the following code to
output just one zero. The code passes JSLint.

     /*jslint devel: true */

     (function () {
         'use strict';

         var isOneWayFlight = true, i;

         for (i = 0; i < isOneWayFlight ? 1 : 2; i += 1) {
             console.log(i);
         }
     }());

Instead, the runtime enters an infinite loop. It outputs: 0, 1, 2, ...

Correct version of the for statement, doing what I want:

     for (i = 0; i < (isOneWayFlight ? 1 : 2); i += 1) {
         console.log(i);
     }

That's just FYI.

#3119 From: Keradus <keradus@...>
Date: Tue Feb 5, 2013 5:30 pm
Subject: Re: [jslint] Just got confused with the `?` operator
keradmaster
Send Email Send Email
 
It's a matter of priority.
First "<" will be executed, then "?".

So
i < isOneWayFlight ? 1 : 2
is the same as
(i < isOneWayFlight) ? 1 : 2

regarding to initial values:
true ? 1 : 2 => 1


And then your loop looks like this:
for (i = 0; 1; i += 1) {...}
That's why it's continues indefinitely




--
Keradus

#3120 From: "Felix E. Klee" <felix.klee@...>
Date: Tue Feb 5, 2013 5:40 pm
Subject: Re: [jslint] Just got confused with the `?` operator
feklee
Send Email Send Email
 
On Tue, Feb 5, 2013 at 6:30 PM, Keradus <keradus@...> wrote:
> It's a matter of priority.

I know. Still the error slipped in, out of sloppiness, like many errors
that JSLint is designed to capture.

#3121 From: "george_weilenmann" <abyssoft@...>
Date: Tue Feb 5, 2013 10:17 pm
Subject: Re: [jslint] Just got confused with the `?` operator
george_weile...
Send Email Send Email
 
This is more of an error on the part of the knowledge of the developer
then on the part of JSLint. The code pattern is perfectly valid and not
confusing to someone who has a good grasp on operator precedence.
even if JSLint was to require () around the ternary operator and
results.
Such that your line
for (i = 0; i < isOneWayFlight ? 1 : 2; i += 1) {
would have thrown an error for missing () around ternary.You still could
have done
for (i = 0; (i < isOneWayFlight ? 1 : 2); i += 1) {
and the same error would have occurred in your logic.
See http://www.javascriptkit.com/jsref/precedence_operators.shtml for a
nice table on precedence of operators.


--- In jslint_com@yahoogroups.com, "Felix E. Klee"  wrote:
>
> On Tue, Feb 5, 2013 at 6:30 PM, Keradus  wrote:
> > It's a matter of priority.
>
> I know. Still the error slipped in, out of sloppiness, like many
errors
> that JSLint is designed to capture.
>



[Non-text portions of this message have been removed]

#3122 From: "Felix E. Klee" <felix.klee@...>
Date: Tue Feb 5, 2013 11:10 pm
Subject: Re: [jslint] Just got confused with the `?` operator
feklee
Send Email Send Email
 
On Tue, Feb 5, 2013 at 11:17 PM, george_weilenmann <abyssoft@...>
wrote:
> This is more of an error on the part of the knowledge of the developer

Exactly not. I'm a C programmer for more than 20 years, and I'm well
versed with its operator precedence, which is similar to that of
JavaScript. I frequently use the `?` operator, and without any issues.

I just wanted to point out what happened to me today. That's all.

#3123 From: "douglascrockford" <douglas@...>
Date: Wed Feb 6, 2013 3:47 am
Subject: Re: Just got confused with the `?` operator
douglascrock...
Send Email Send Email
 
--- In jslint_com@yahoogroups.com, "Felix E. Klee"  wrote:
>     /*jslint devel: true */
>
>     (function () {
>         'use strict';
>
>         var isOneWayFlight = true, i;
>
>         for (i = 0; i < isOneWayFlight ? 1 : 2; i += 1) {
>             console.log(i);
>         }
>     }());
>
> Instead, the runtime enters an infinite loop. It outputs: 0, 1, 2, ...
>
> Correct version of the for statement, doing what I want:
>
>     for (i = 0; i < (isOneWayFlight ? 1 : 2); i += 1) {
>         console.log(i);
>     }


Thanks. Please try it now.

#3124 From: "george_weilenmann" <abyssoft@...>
Date: Wed Feb 6, 2013 4:12 am
Subject: Re: Just got confused with the `?` operator
george_weile...
Send Email Send Email
 
Nice compromise. Works great and indeed improves readability.

--- In jslint_com@yahoogroups.com, "Felix E. Klee"  wrote:
>
> Well, today I'm not in good shape, and I expected the following code to
> output just one zero. The code passes JSLint.
>
>     /*jslint devel: true */
>
>     (function () {
>         'use strict';
>
>         var isOneWayFlight = true, i;
>
>         for (i = 0; i < isOneWayFlight ? 1 : 2; i += 1) {
>             console.log(i);
>         }
>     }());
>
> Instead, the runtime enters an infinite loop. It outputs: 0, 1, 2, ...
>
> Correct version of the for statement, doing what I want:
>
>     for (i = 0; i < (isOneWayFlight ? 1 : 2); i += 1) {
>         console.log(i);
>     }
>
> That's just FYI.
>

#3125 From: "Felix E. Klee" <felix.klee@...>
Date: Thu Feb 7, 2013 9:49 am
Subject: Re: [jslint] Re: Just got confused with the `?` operator
feklee
Send Email Send Email
 
On Wed, Feb 6, 2013 at 3:47 AM, douglascrockford <douglas@...> wrote:
> Please try it now.

So quick - thanks! :-)

#3126 From: "douglascrockford" <douglas@...>
Date: Sun Feb 17, 2013 12:33 am
Subject: Context Coloring
douglascrock...
Send Email Send Email
 
I have added an experimental context coloring feature to JSLint.
It is intended to provide context coloring in text editors and
IDEs. Context coloring gives a different color to each level of
function nesting. Variables are displayed with the color in
which they were defined. Context coloring makes it easier to
see the structure of programs and the closure of variables.

A new function is provided, JSLINT.color(data). It requires the
use of a data argument that can be obtained from JSLINT.data().
JSLINT.color(data) returns an array of objects, each object
containing four properties: {
     line: a source file line number,
     level: a nesting level number (0 is global,
            deeper functions have higher numbers),
     from: a starting position on the line,
     thru: one past the end of a run of a single color
}.

For example:

function MONAD() {
````'use strict';
````return function unit(value) {
````````var monad = Object.create(null);
````````monad.bind = function (func) {
````````````return func(value);
````````};
````````return monad;
````};
}

[
     {"line": 1, "level": 1, "from": 1, "thru": 9},
     {"line": 1, "level": 0, "from": 10, "thru": 15},
     {"line": 1, "level": 1, "from": 15, "thru": 19},
     {"line": 2, "level": 1, "from": 5, "thru": 18},
     {"line": 3, "level": 1, "from": 5, "thru": 11},
     {"line": 3, "level": 2, "from": 12, "thru": 20},
     {"line": 3, "level": 1, "from": 21, "thru": 25},
     {"line": 3, "level": 2, "from": 25, "thru": 34},
     {"line": 4, "level": 2, "from": 9, "thru": 20},
     {"line": 4, "level": 0, "from": 21, "thru": 27},
     {"line": 4, "level": 2, "from": 27, "thru": 41},
     {"line": 5, "level": 2, "from": 9, "thru": 21},
     {"line": 5, "level": 3, "from": 22, "thru": 39},
     {"line": 6, "level": 3, "from": 13, "thru": 25},
     {"line": 6, "level": 2, "from": 25, "thru": 30},
     {"line": 6, "level": 3, "from": 30, "thru": 32},
     {"line": 7, "level": 3, "from": 9, "thru": 11},
     {"line": 8, "level": 2, "from": 9, "thru": 22},
     {"line": 9, "level": 2, "from": 5, "thru": 7},
     {"line": 10, "level": 1, "from": 1, "thru": 2}
]

Each level will have its own color. I have been using these:
0 white
1 green
2 yellow
3 blue
4 red
5 cyan
6 magenta
7 gray

It might be helpful to provide a convenient mechanism for
switching between context coloring and kindergarten coloring.

JSLINT.property is an object containing the counts of all of
the property names found in a file. It could be used to provide
property names for auto-completion.

#3127 From: "douglascrockford" <douglas@...>
Date: Tue Feb 19, 2013 6:20 pm
Subject: wiki
douglascrock...
Send Email Send Email
 
The experiment of using Yahoo Group's Database to manage JSLint configurations
has not turned out well. So now I am going to try using Github's wiki. If you
have information about deployment of JSLint that you want to share, please add
it to https://github.com/douglascrockford/JSLint/wiki/JSLINT

Thank you.

#3128 From: "douglascrockford" <douglas@...>
Date: Tue Feb 19, 2013 11:36 pm
Subject: es5
douglascrock...
Send Email Send Email
 
JSLint now requires an ECMAScript Fifth Edition engine to run. It will continue
to evaluate programs written for ES3 or ES5.

#3129 From: "Felix E. Klee" <felix.klee@...>
Date: Wed Feb 20, 2013 2:14 pm
Subject: Re: [jslint] es5
feklee
Send Email Send Email
 
On Tue, Feb 19, 2013 at 11:36 PM, douglascrockford
<douglas@...> wrote:
> JSLint now requires an ECMAScript Fifth Edition engine to run. It will
> continue to evaluate programs written for ES3 or ES5.

Any idea what is a good method to run JSLint offline on Windows (for
live linting in EMACS)? Can it be run with Node.js?

So far I have been using [jslint-for-wsh][1], but that stopped working
properly already some weeks ago, at least when used with EMACS. The
issue: errors are reported on the wrong lines

[1]: http://code.google.com/p/jslint-for-wsh/

Messages 3099 - 3129 of 3202   Oldest  |  < Older  |  Newer >  |  Newest
Add to My Yahoo!      XML What's This?

Copyright © 2010 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines NEW - Help