Loading ...
Sorry, an error occurred while loading the content.

Re: Question about ===

Expand Messages
  • pauanyu
    ... location is an object, use location.href instead: if (location.href === base_url) { } If that doesn t solve the problem... we will need more information,
    Message 1 of 9 , Oct 2, 2009
    • 0 Attachment
      --- In jslint_com@yahoogroups.com, Nagy Endre <forewer2000@...> wrote:
      >
      > I have a string - base_url - with an url inside. I want to test if this is the current url on my site.
      > If I use
      > window.location === base_url
      > jslint are ok, but the result is false because the type are not the same I think.
      > for
      > window.location == base_url
      > I get true, but this is not a good practice. What is the good practice in this case?
      >
      > Thanks
      >

      location is an object, use location.href instead:

      if (location.href === base_url) {
      }

      If that doesn't solve the problem... we will need more information, like the actual code you are using.
    • Douglas Crockford
      ... They aren t constants. They are mutable properties of a function. ... Variables should be declared before they are used. The function statement is a
      Message 2 of 9 , Oct 2, 2009
      • 0 Attachment
        --- In jslint_com@yahoogroups.com, Toby Maxwell-Lyte <toby.maxwelllyte@...> wrote:

        > Thanks, it just seems logical to have constants at the top of the
        > file.

        They aren't constants. They are mutable properties of a function.

        > What is the motivation behind this rule?

        Variables should be declared before they are used.
        The function statement is a variable declaration.
      • Toby Maxwell-Lyte
        ... Thanks for the explanations gents.
        Message 3 of 9 , Oct 2, 2009
        • 0 Attachment
          2009/10/2 Douglas Crockford <douglas@...>:
          > --- In jslint_com@yahoogroups.com, Toby Maxwell-Lyte <toby.maxwelllyte@...> wrote:
          >
          >> Thanks, it just seems logical to have constants at the top of the
          >> file.
          >
          > They aren't constants. They are mutable properties of a function.
          >
          >> What is the motivation behind this rule?
          >
          > Variables should be declared before they are used.
          > The function statement is a variable declaration.
          >

          Thanks for the explanations gents.
        Your message has been successfully submitted and would be delivered to recipients shortly.