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

  • Home
  • SEARCH
  • 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 8520613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:35:00+00:00 2026-06-11T06:35:00+00:00

From MDN : Using with is not recommended, and is forbidden in ECMAScript 5

  • 0

From MDN:

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.

It seems like a great/useful/convenient feature. Why is it frowned upon? What other ways are there to achieve that effect? I don’t want to have to go:

veryLongNS.y = veryLongNS.myFunc(veryLongNS.x);
veryLongNS.z = 6;
veryLongNS.otherFunc();
veryLongNS.a = {
    a:1,
    b:2,
    c:veryLongNS.processThree(3)
};
  • 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-11T06:35:01+00:00Added an answer on June 11, 2026 at 6:35 am

    Here’s a related answer:
    Are there legitimate uses for JavaScript's "with" statement?

    Also: http://yuiblog.com/blog/2006/04/11/with-statement-considered-harmful/

    How about the following as an alternative?

    (function(obj) {
        obj.y = obj.myFunc(obj.x);
        obj.z = 6;
        obj.otherFunc();
        obj.a = {a:1,b:2,c:obj.processThree(3)};
    })(myAwkwardlyNamedObjectToBeUsedAsANameSpaceThatIWishToModifyAndNotJustRead);
    

    Edit: For clarity and posterity, this is also possible (and in most cases would be preferred over the above — I wouldn’t recommend doing it in the global scope, but I wouldn’t recommend doing anything in the global scope):

    function someFunction() {
        // in some function
        var obj = myAwkwardlyNamedObjectToBeUsedAsANameSpaceThatIWishToModifyAndNotJustRead;
        obj.y = obj.myFunc(obj.x);
        obj.z = 6;
        obj.otherFunc();
        obj.a = {a:1,b:2,c:obj.processThree(3)};
        // ... any other stuff in the function
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to bubble some information from a frame to its parent object (information
From a standpoint of using XHTML 1.0 Strict as DOCTYPE -- would the input
I'm trying to run the code from here MDN: Generators and Iterators function fib()
I'm trying to follow some example code from microsofts mdn site.. var WshShell =
From the Scala API , I got the following example, which does not compile;
From time to time, I find myself using the same group of statements and
All sites that list css properties such like MDN or w3schools list every CSS
from the table realestate I want to get the number of records where the
From: Pro PHP and jQuery: ■ Tip The values returned are CSS shorthand properties.3
Does the Date object in Javascript ever use a non-Gregorian calendar? The MDN and

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.