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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:43:13+00:00 2026-05-31T21:43:13+00:00

Once, I saw an example like this: var a, x, y; var r =

  • 0

Once, I saw an example like this:

var a, x, y;
var r = 10;
with (Math) {
  a = PI * r * r;
  x = r * cos(PI);
  y = r * sin(PI / 2);
}

And it looks very convenience, because that way I don’t have to type all the Math.s.

But when I take a look at the MDN, it says:

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.

So is it okay to use with()? In HTML5?

  • 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-31T21:43:15+00:00Added an answer on May 31, 2026 at 9:43 pm

    The MDN you linked says Using with is not recommended…
    with is an excellent way of making spaghetti code for lunch.

    You might like it, but the guy that will need to debug it will curse you.

    javascript has some very weird operators, like the comma operator(,).
    Can you understand what the following code does?

    var a = "a";
    var b = "b";
    a = [b][b = a,0];
    

    Well it swaps a and b… You don’t understand , so as the guy that will need maintain your with code. Don’t use hacks, hacks are cool in charades games, not in real code.


    When is the comma operator useful?
    The comma swap Fiddle

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

Sidebar

Related Questions

I believe that I once saw a website that is like an online Python
I once saw that was possible to do something like adding a key in
I saw something once for wrappers used to do this but it asked for
I'm sure I saw this happening to me once. In a 64-bit OS with
I once saw this feature in action but I don't know how to turn
I have for loop doubt that I need to ask . once i saw
I once used a code snippet I saw/found in the past that would turn
Once I saw a DB made in MS Access that worked as a normal
I once saw a framework or code from some PHP that had an error
I once saw this line of code: std::cout %lt;%lt; Hello world! %lt;%lt; std:: endl;

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.