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 697201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:08:37+00:00 2026-05-14T03:08:37+00:00

I recently made my own Javascript library and I initially used the following pattern:

  • 0

I recently made my own Javascript library and I initially used the following pattern:

var myLibrary = (function () {

  var someProp = "...";

  function someFunc() {
    ...
  }

  function someFunc2() {
    ...
  }

  return {
     func: someFunc,
     fun2: someFunc2,
     prop: someProp;
  }

}());

The problem with this is that I can’t really use code completion because the IDE doesn’t know about the properties that the function literal is returning (I’m using IntelliJ IDEA 9 by the way).

I’ve looked at jQuery code and tried to do this:

(function(window, undefined) {
    var myLibrary = (function () {

      var someProp = "...";

      function someFunc() {
        ...
      }

      function someFunc2() {
        ...
      }

      return {
         func: someFunc,
         fun2: someFunc2,
         prop: someProp;
      }

    }());

    window.myLibrary = myLibrary;
}(window));

I tried this, but now I have a different problem. The IDE doesn’t really pick up on myLibrary either.

The way I’m solving the problem now is this way:

var myLibrary = {
   func: function() { },
   func2: function() { },
   prop: ""
};

myLibrary = (function () {

  var someProp = "...";

  function someFunc() {
    ...
  }

  function someFunc2() {
    ...
  }

  return {
     func: someFunc,
     fun2: someFunc2,
     prop: someProp;
  }

}());

But that seems kinda clunky, and I can’t exactly figure out how jQuery is doing it. Another question I have is how to handle functions with arbitrary numbers of parameters.

For example, jQuery.bind can take 2 or 3 parameters, and the IDE doesn’t seem to complain. I tried to do the same thing with my library, where a function could take 0 arguments or 1 argument. However, the IDE complains and warns that the correct number of parameters aren’t being sent in. How do I handle this?

EDIT

I’m starting to wonder if this is an Idea9 issue because jQuery has the same problem. I don’t seem to have this problem in other projects though.

  • 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-14T03:08:37+00:00Added an answer on May 14, 2026 at 3:08 am

    I’m using IDEA with yahoo module pattern and my autocomplete works. Google for yahoo module pattern.

    http://www.yuiblog.com/blog/2007/06/12/module-pattern/

    http://ajaxian.com/archives/a-javascript-module-pattern


    TEST = function() {
        var SOME_CONSTANT='asd';
    
        function privateStuff(){
            var a = 'asd';
            return a;
        }
    
        return{
            someArray:[],
    
            someMethod: function(foo, bar){
    
                var foo = *1
            }
            ,
    
            myProperty:'test'
        }
    }();
    
    TEST.*2
    

    with *1 and *2 i marked places where i tried auto complete.

    in *1 i get SOME_CONSTANT and privateStuff method, and if i put this.(autocomplete) i get access to all the methods and properties inside of return {} block

    when i try autocomplete on *2 i get all the methods and properties inside return {} block.
    SOME_CONSTANT and privateStuff method are invisibile there, because they are “private”.

    For me that level of autocomplete is quite fine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have made Catifier.com recently, and once the user sets their own background image,
I recently made an App for IOS with Phonegap . I used the html5
I recently made an update to JasperReports library version 4.1.3. Previously, I had a
I recently made the following (i believe important) changes to my system Actually I
I am used to 2000 and recently made the switch to 2008. If anyone
Recently I've been designing a Thread class library, I've made a Thread abstract class
I recently made index on a highly used view but it resulted in increase
I recently made a menu screen to my cocos2d app where I have attached
I recently made some reference additions to a project in my solution and made
I recently made a very simple practice program in Python, that takes user input

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.