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

Globals / Read Only

Expand Messages
  • g2223060
    I have some legacy JavaScript that I am trying to clean up, which of course involves heavy linting [;)] The code was all global, of course, which I have
    Message 1 of 2 , Apr 21 1:44 PM
    View Source
    • 0 Attachment
      I have some legacy JavaScript that I am trying to clean up, which of
      course involves heavy linting [;)]

      The code was all global, of course, which I have wrapped in:

      (function(){...})();

      But one of the functions needs to be exposed globally, since I don't
      want to modify all the uses of it throughout the application:

      Before, it looked like this:
      function FormatMask(inputControl, format, regex){...}

      In order to make it global, I added /*global FormatMask */ for JSLint
      and then changed the code like this:

      FormatMask = function(inputControl, format, regex){...}

      JSLint complains: Problem at line 131 character 5: Read only.

      How can I fix this?



      [Non-text portions of this message have been removed]
    • Aseem Kishore
      /*global FormatMask: true */ The : true part tells JSLint that that global variable is read-write, not read-only. Aseem ... [Non-text portions of this
      Message 2 of 2 , Apr 21 1:51 PM
      View Source
      • 0 Attachment
        /*global FormatMask: true */

        The ": true" part tells JSLint that that global variable is read-write, not
        read-only.

        Aseem

        On Wed, Apr 21, 2010 at 1:44 PM, g2223060 <g2223060@...> wrote:

        >
        >
        > I have some legacy JavaScript that I am trying to clean up, which of
        > course involves heavy linting [;)]
        >
        > The code was all global, of course, which I have wrapped in:
        >
        > (function(){...})();
        >
        > But one of the functions needs to be exposed globally, since I don't
        > want to modify all the uses of it throughout the application:
        >
        > Before, it looked like this:
        > function FormatMask(inputControl, format, regex){...}
        >
        > In order to make it global, I added /*global FormatMask */ for JSLint
        > and then changed the code like this:
        >
        > FormatMask = function(inputControl, format, regex){...}
        >
        > JSLint complains: Problem at line 131 character 5: Read only.
        >
        > How can I fix this?
        >
        > [Non-text portions of this message have been removed]
        >
        >
        >


        [Non-text portions of this message have been removed]
      Your message has been successfully submitted and would be delivered to recipients shortly.