Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6807731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:52:05+00:00 2026-05-26T19:52:05+00:00

I have several of these errors and I am not sure how to properly

  • 0

I have several of these errors and I am not sure how to “properly” solve it, the thing is that I have many javascript files (Seperated for easier maintainability) and I include plugins et cetera.

So in this example I use shortcut which is from http://www.openjs.com/scripts/events/keyboard_shortcuts/

This just defines shortcut to

shortcut = {.......

then when I in my code use it like

 shortcut.add("F1", function () { showDialog(); }, { 'type': 'keydown', 'propagate': false, 'target': editor_document });

jslint will complain that

JS Lint: ‘shortcut’ was used before it was defined.

I also have my own code where I use functions declared in other files, so what is the “right” way to solve this

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T19:52:06+00:00Added an answer on May 26, 2026 at 7:52 pm

    If the variable is defined by another file, you can tell JSLint by providing a comment in the following format:

    /*global shortcut*/
    

    You can do this for a number of variables by comma separating them. Appending : and true or false (defaults to false) will specify whether the variable can be reassigned by the current file:

    /*global shortcut:false, otherVar:true*/
    

    You’re missing the var keyword, which is used to define a variable for the global and function scopes.

    var shortcut = { }
    

    You need to use var for every variable defined, else you’ll run into a mass of problems.

    It is possible to create implicit globals by omitting the var keyword, but it’s highly frowned upon and not at all recommended. If you need to create a global variable from an inner scope, you can add the object to window or, depending on the context, this:

    function defineShortcut() {
        window.shortcut = {};
        /* or this.shortcut = {}; */
    }
    
    defineShortcut();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have some Orders that can have several Items and these Items have an
We have several cron jobs that ftp proxy logs to a centralized server. These
I have several divs that share a common class. If one of these divs
I have several methods that have a return type IEnumerable<T> . These methods are
I have seen several sites where these social share buttons looks perfectly horizontal aligned.
i have several classes with members called 'Id'. Originally i wanted to store these
I have several articles on a Joomla (1.5) site. These articles are public --
I have several classes such as Order, Customer, etc. These classes serve for holding
Suppose I have several services represented by classes ServiceA, ServiceB, ServiceC etc. These services
I have an app with several different tabs. The first of these tabs should

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.