How do objects work sequentially/procedurally in javascript?

I am new to javascript but have used other languages before (primarily php).

How do objects work within code procedurally/sequentially?
The following has weird results for me:

var person =
{
	name: ‘Fred’
}

console.log(person); // says Robert – I expected Fred.

person.name = ‘Robert’;
console.log(person); // says Robert

It looks like person.name is running out of sequence. I have heard javascript “hoists” functions, but how does it work here with objects? What is going on?

I tried this code again after posting and got the expected result. Strange - my only guess is that I messed up in previous attempts. I tried to delete the post but couldn’t. Sorry.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.