Search the web
Sign In
New User? Sign Up
jslint_com · JSLint.com
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want your group to be featured on the Yahoo! Groups website? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
console read only   Message List  
Reply | Forward Message #699 of 993 |
Re: console read only

--- In jslint_com@yahoogroups.com, "Douglas Crockford" <douglas@...> wrote:
>
> --- In jslint_com@yahoogroups.com, "Noah Peters" <boyopeg@> wrote:
> >
> > With the newest version of JSLint I am having a frequent error on this code
block:
> >
> > if (typeof console==="undefined") {
> > console = {
> > log: function() {},
> > dir: function() {},
> > trace: function() {}
> > }
> > }
>
> Either turn off the Assume a Browser option, or add this comment:
>
> /*global console: true*/
>

Awesome, thanks!




Mon Jun 29, 2009 8:11 pm

boyopeg
Offline Offline
Send Email Send Email

Forward
Message #699 of 993 |
Expand Messages Author Sort by Date

With the newest version of JSLint I am having a frequent error on this code block: if (typeof console==="undefined") { console = { log: function() {}, dir:...
Noah Peters
boyopeg
Offline Send Email
Jun 29, 2009
5:00 pm

... Either turn off the Assume a Browser option, or add this comment: /*global console: true*/...
Douglas Crockford
douglascrock...
Offline Send Email
Jun 29, 2009
6:04 pm

... Awesome, thanks!...
Noah Peters
boyopeg
Offline Send Email
Jun 29, 2009
8:12 pm

... Why would you use typeof(console) === "undefined" instead of console === undefined which should be the same thing, but faster?...
sandyhead25
Offline Send Email
Jul 5, 2009
12:33 pm

... if (console === undefined) // could raise ReferenceError if console is not defined if (typeof console === 'undefined') // is safer, tests for the type of...
marcelduran
Online Now Send Email
Jul 6, 2009
3:03 am

... You seem to have confused the result of the test for the operations imposed within the test decision. The typeof operator only tests for the type of the...
sandyhead25
Offline Send Email
Jul 7, 2009
11:16 pm

... No, typeof works on expressions (more precisely UnaryExpressions), including variables and object properties. That means it will also work on implicit...
crlender
Offline Send Email
Jul 8, 2009
1:03 am

... I did not say the test was incorrect. I only said it was inefficient and likely did not accomplish what he expected. ... Unary operators are typically...
sandyhead25
Offline Send Email
Jul 9, 2009
3:27 am

... Firefox. If the ECMA standard is in disagreement with me >then Firefox's interpretation of JavaScript is nonstandard or the standard is wrong. Wow ! Be...
Alexandre Morgaut
morgaut_a
Offline Send Email
Jul 9, 2009
10:05 am

... They're not. ... They don't. ... types were objects, typeof would return "object" for each of them, and would be quite useless. typeof "" -->...
crlender
Offline Send Email
Jul 9, 2009
2:56 pm

... They why are unary operators frowned upon by the jslint tool? ... Operators require something to act upon. ... Functions are objects. Types are derived...
sandyhead25
Offline Send Email
Jul 9, 2009
9:57 pm

... What?...
Douglas Crockford
douglascrock...
Offline Send Email
Jul 9, 2009
10:03 pm

... The most significantly common increment and decrement operators are frowned upon by the tool. The unary plus operator is not frowned upon, but is...
sandyhead25
Offline Send Email
Jul 10, 2009
9:10 am

right, but my point was: "if (console === undefined)" only works when console variable is defined. [Non-text portions of this message have been removed]...
Marcel Duran
marcelduran
Online Now Send Email
Jul 8, 2009
1:10 am

... No, because if the variable is defined then "if (console === undefined)" will not work, or rather it will evaluate to false. If console is defined then...
sandyhead25
Offline Send Email
Jul 9, 2009
2:02 am

by "work" I meant "will evaluate the expression" not the result itself.again: if console is not defined, your test, if (console === undefined) will raise a...
Marcel Duran
marcelduran
Online Now Send Email
Jul 9, 2009
2:37 am

... I have discovered the root of this complication. If a variable is declared but not assigned or not used this text works perfectly fine. If the variable...
sandyhead25
Offline Send Email
Jul 9, 2009
3:35 am

... This whole thread has spiraled out of control. Here's the simple answer: If you use (console === undefined), and console has not been declared, it will...
pauanyu
Offline Send Email
Jul 10, 2009
8:49 pm
Advanced

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