How do you know where to exactly pull properties from objects after a new evaluation of object literal?
up vote
-3
down vote
favorite
everyone! I'm having an issue understanding this program:
var zomB = {
name: "Zom B.",
peepsEaten: 5
},
zomA = zomB,
oldHome = "Atlanta",
newHome = oldHome;
zomA.name = "Zom A.";
//outputs ZomA
console.log(zomB.name);
I'm confused as to why ZomA outputted by the zomB.name. Can someone please explain this?
javascript arrays object
New contributor
add a comment |
up vote
-3
down vote
favorite
everyone! I'm having an issue understanding this program:
var zomB = {
name: "Zom B.",
peepsEaten: 5
},
zomA = zomB,
oldHome = "Atlanta",
newHome = oldHome;
zomA.name = "Zom A.";
//outputs ZomA
console.log(zomB.name);
I'm confused as to why ZomA outputted by the zomB.name. Can someone please explain this?
javascript arrays object
New contributor
The output I get isZom A.
. You may have made a typo. If so please fix your question
– smac89
Nov 18 at 2:40
3
Possible duplicate of Is JavaScript a pass-by-reference or pass-by-value language?
– connexo
Nov 18 at 2:42
In JS, objects (alongside 'special' objects like functions and arrays) are passed by reference , whereas primitives (like Strings, Number and Boolean) are passed by value .
– connexo
Nov 18 at 2:43
Possible duplicate of Pass-by-reference JavaScript objects
– Randy Casburn
Nov 18 at 2:44
I don't understand why you are confused about. Can you please explain what you are confused about and what your expected output is?
– NewToJS
Nov 18 at 2:49
add a comment |
up vote
-3
down vote
favorite
up vote
-3
down vote
favorite
everyone! I'm having an issue understanding this program:
var zomB = {
name: "Zom B.",
peepsEaten: 5
},
zomA = zomB,
oldHome = "Atlanta",
newHome = oldHome;
zomA.name = "Zom A.";
//outputs ZomA
console.log(zomB.name);
I'm confused as to why ZomA outputted by the zomB.name. Can someone please explain this?
javascript arrays object
New contributor
everyone! I'm having an issue understanding this program:
var zomB = {
name: "Zom B.",
peepsEaten: 5
},
zomA = zomB,
oldHome = "Atlanta",
newHome = oldHome;
zomA.name = "Zom A.";
//outputs ZomA
console.log(zomB.name);
I'm confused as to why ZomA outputted by the zomB.name. Can someone please explain this?
var zomB = {
name: "Zom B.",
peepsEaten: 5
},
zomA = zomB,
oldHome = "Atlanta",
newHome = oldHome;
zomA.name = "Zom A.";
//outputs ZomA
console.log(zomB.name);
var zomB = {
name: "Zom B.",
peepsEaten: 5
},
zomA = zomB,
oldHome = "Atlanta",
newHome = oldHome;
zomA.name = "Zom A.";
//outputs ZomA
console.log(zomB.name);
javascript arrays object
javascript arrays object
New contributor
New contributor
edited Nov 18 at 2:43
NewToJS
2,3413819
2,3413819
New contributor
asked Nov 18 at 2:37
Newbie Coder
1
1
New contributor
New contributor
The output I get isZom A.
. You may have made a typo. If so please fix your question
– smac89
Nov 18 at 2:40
3
Possible duplicate of Is JavaScript a pass-by-reference or pass-by-value language?
– connexo
Nov 18 at 2:42
In JS, objects (alongside 'special' objects like functions and arrays) are passed by reference , whereas primitives (like Strings, Number and Boolean) are passed by value .
– connexo
Nov 18 at 2:43
Possible duplicate of Pass-by-reference JavaScript objects
– Randy Casburn
Nov 18 at 2:44
I don't understand why you are confused about. Can you please explain what you are confused about and what your expected output is?
– NewToJS
Nov 18 at 2:49
add a comment |
The output I get isZom A.
. You may have made a typo. If so please fix your question
– smac89
Nov 18 at 2:40
3
Possible duplicate of Is JavaScript a pass-by-reference or pass-by-value language?
– connexo
Nov 18 at 2:42
In JS, objects (alongside 'special' objects like functions and arrays) are passed by reference , whereas primitives (like Strings, Number and Boolean) are passed by value .
– connexo
Nov 18 at 2:43
Possible duplicate of Pass-by-reference JavaScript objects
– Randy Casburn
Nov 18 at 2:44
I don't understand why you are confused about. Can you please explain what you are confused about and what your expected output is?
– NewToJS
Nov 18 at 2:49
The output I get is
Zom A.
. You may have made a typo. If so please fix your question– smac89
Nov 18 at 2:40
The output I get is
Zom A.
. You may have made a typo. If so please fix your question– smac89
Nov 18 at 2:40
3
3
Possible duplicate of Is JavaScript a pass-by-reference or pass-by-value language?
– connexo
Nov 18 at 2:42
Possible duplicate of Is JavaScript a pass-by-reference or pass-by-value language?
– connexo
Nov 18 at 2:42
In JS, objects (alongside 'special' objects like functions and arrays) are passed by reference , whereas primitives (like Strings, Number and Boolean) are passed by value .
– connexo
Nov 18 at 2:43
In JS, objects (alongside 'special' objects like functions and arrays) are passed by reference , whereas primitives (like Strings, Number and Boolean) are passed by value .
– connexo
Nov 18 at 2:43
Possible duplicate of Pass-by-reference JavaScript objects
– Randy Casburn
Nov 18 at 2:44
Possible duplicate of Pass-by-reference JavaScript objects
– Randy Casburn
Nov 18 at 2:44
I don't understand why you are confused about. Can you please explain what you are confused about and what your expected output is?
– NewToJS
Nov 18 at 2:49
I don't understand why you are confused about. Can you please explain what you are confused about and what your expected output is?
– NewToJS
Nov 18 at 2:49
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Newbie Coder is a new contributor. Be nice, and check out our Code of Conduct.
Newbie Coder is a new contributor. Be nice, and check out our Code of Conduct.
Newbie Coder is a new contributor. Be nice, and check out our Code of Conduct.
Newbie Coder is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53357401%2fhow-do-you-know-where-to-exactly-pull-properties-from-objects-after-a-new-evalua%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
The output I get is
Zom A.
. You may have made a typo. If so please fix your question– smac89
Nov 18 at 2:40
3
Possible duplicate of Is JavaScript a pass-by-reference or pass-by-value language?
– connexo
Nov 18 at 2:42
In JS, objects (alongside 'special' objects like functions and arrays) are passed by reference , whereas primitives (like Strings, Number and Boolean) are passed by value .
– connexo
Nov 18 at 2:43
Possible duplicate of Pass-by-reference JavaScript objects
– Randy Casburn
Nov 18 at 2:44
I don't understand why you are confused about. Can you please explain what you are confused about and what your expected output is?
– NewToJS
Nov 18 at 2:49