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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:24:58+00:00 2026-06-04T23:24:58+00:00

I am using underscore.js library has a clone method. var newObject = _.clone(oldObject); I

  • 0

I am using underscore.js library has a clone method.

var newObject = _.clone(oldObject);

I read from one of the comments that it’s a shallow clone. I want to make a clone of an object and pass it to different functions.

When i alter the newObject which is inside the function A(), i get the following results…

{
    'Des': 'Some Des'
    'Des1': 4,
    'Des2': {
        "ChildDes": 0,

    },
},

But when i pass the newObject which is the clone object to an another function B(), i get alert value as [Object,Object]. Why? I am not able to print the value like this..

function B(newObject){
   alert(newObject.Des2);
}
  • 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-04T23:24:59+00:00Added an answer on June 4, 2026 at 11:24 pm

    A “shallow copy” is a copy, that just copies all members. If one of the members is a reference to an object, than changes on the copied reference will effect the original one. A “deep copy” will copy the objects too, so that changes on deep copied elements won’t effect the original object.
    Deep copies are sometimes hard to achieve since an objects member could have a reference on the object itself.

    Play a little bit with different copy styles and see for yourself what can happen. See also: What does it mean to clone() an object?

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

Sidebar

Related Questions

I am using underscore.js's templating capabilities from backbone.js, I have the following template that
Using the javascript library underscore.js (v.1.3.1), I've reproduced the following on the mac in
I have been using underscore library for many things, however am having issues in
I'm using the following code (with the Underscore.js library) to add the attributes target=_blank
I'm using backbone.js, underscore.js and jQuery. I took the following sample code from http://jsfiddle.net/thomas/C9wew/6/
I am using Underscore library and using its template feature. But i am getting
I am using underscore.js 's templating library, and I am not sure how to
I am using the underscore.js template library with my backbone example. My template looks
I'm using Backbone and therefore Underscore to render my templates. My templates get rendered
I am using VS2008 and creating forms. By default, the underscore of the character

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.