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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:09:15+00:00 2026-06-17T06:09:15+00:00

Is there anything in javascript that is the equivalent of java static imports? For

  • 0

Is there anything in javascript that is the equivalent of java static imports? For example, if I have a Math class that looks like

com.example.Math = function() {

   function1(...) {}
   function2(...) {}

}

Now some of these functions are naturally chained together such that the output to one is the input to another. I can do something like

com.example.Math.function2(com.example.Math.function1());

This is a little ugly looking, and I would really like to do something like:

function2(function1())

But I don’t want to put function1 and function2 in the global namespace. Is this possible?

  • 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-06-17T06:09:17+00:00Added an answer on June 17, 2026 at 6:09 am

    Yes, there is. It’s called with.

    with (com.example.Math) {
        function2(function1());
    }
    

    That said:

    Using with is not recommended, and is forbidden in ECMAScript 5 strict mode. The recommended alternative is to assign the object whose properties you want to access to a temporary variable.

    For example:

    var m = com.example.Math;
    m.function2(m.function1());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there anything in Python that works like the final keyword in Java -
Is there anything like: http://nathansjslessons.appspot.com/lesson?id=1000 Something where I can learn and practice javascript? I
I wonder if there are anything like a Javascript template system that wraps HTML,
The javascript one seems pretty simple, just localStorage.clear(). Is there anything similar to that
Is there anything particularly bad about doing something like this in Javascript: myapp.someObject =
Is there anything readily available in JavaScript (i.e. not through plugins) that allows me
Is there anything like asp.net transactions in Android SQLite? I am doing some processing
Is there anything like this outside of the application delegate? I would just like
Is there anything in Python akin to Java's JLS or C#'s spec?
I have some javascript functions that take about 1 to 3 seconds. (some loops

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.