Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Object-Oriented JavaScript (2015) Introduction to Methods Modifying Objects with Methods

Deepak Sharma
Deepak Sharma
1,987 Points

How the browser is preserving the previous value?

When different values were entered through JavaScript console while testing the add functionality how the browser was storing the previous value.I mean first we entered 1 and then 2.Each and every request shouldn't reinitialize the values again or how it happens internally?

2 Answers

Hey Deepak,

The browser will persist the data until you hit refresh. If you wanted it to stick around after hitting refresh, there are technologies like HTML5 Local Storage, cookies etc. But that's not what's happening here.

Hi Deepak,

I know is is old thread but. When ever you add a variable it will add that variable to the window object.

So if you were in javascript console and did this...

var zzz = "Freddie

And then, also in the console do this

window

You will see all the objects inside the window object, scroll down and you'll find your variable.