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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:40:31+00:00 2026-06-18T00:40:31+00:00

I have lot enough functions, which look like: var functionName = function(e) { //

  • 0

I have lot enough functions, which look like:

var functionName = function(e) {
  // 
};

where all the parameters are getting passed in in a single container e. Most times values are simple values (no functions), ex.:

{ parameter1: 1, parameter2: "Name", parameter3:{ subParameter1: "A"}}

But there’re times when I pass in functions as in: { p2:function(){...} }

I have two options when it comes to utilising parameter values:

Options 1: get parameter values from the chain, starting from e: e.parameter1, e.parameter3.subParameter1 etc.

Option 2: use cached parameter values:

var parameter1 = e.parameter1;
var subParameter1 = e.parameter3.subParameter1;

The second option improves readability but increases the number of vars and the size of the code base. On another hand it’s much drier when using long chains, i.e. e.p1.p2.p3 etc.

What reasoning should I use for choosing between those two options?

**Update 1 - the question sounds quite subjective, let me re-prase it.** 

I don’t mind using chains all the way, no local vars codebase is smaller, I can always figure out what’s what, are the any cases when caching is a must?

  • 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-18T00:40:32+00:00Added an answer on June 18, 2026 at 12:40 am

    A combination, based on depth(e.p1 vs e.p1.sp2.ssp3) and frequency of use. Deeper sub-properties and high usage of any sub-property both benefit from caching.

    Nested property look ups can get costly, and caching the value after executing the look up once is valuable if you’re going to use it a lot. This is only more efficient if you’re accessing a particular property on the chain more than once, and the more you access it, the more you benefit from caching.

    If you only have one level deep(e.p1, e.p2, e.p3) and you’re only looking up each property value once, don’t bother.

    If you’re accessing e.p1.sp2.ssp3 all throughout your function, cache it for sure.

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

Sidebar

Related Questions

I have lot of code in my Tornado app which looks like this: @tornado.web.asynchronous
At the moment, I have lot's of Java which does all kind of nifty
I have a lot of pages that are setup like so from an old
I have a jsp which uses a lot of javascript and it's just not
I have a dll which includes a function called ReadPort that reads data from
I have following function which is called continuously from run() of a Thread which
I have lot of products with custom options, now I have requirement to update
We have lot of object with this kind of design : Interface and several
I have a requirement to use date picker in my applicaiton. I have lot
I am creating Excel file download using NOPI libraries. I have lot of data

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.