Click here to Skip to main content
15,878,996 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

Can anyone please tell me how to find out the size of an object in javascript?

Thanks,
Lijo
Posted
Comments
Zoltán Zörgő 10-Dec-12 13:54pm    
By size you mean...? I suppose height and width, but which of them - inner, outer, with, or without padding...? And by object you mean any html element (div for example), or an object created with some embedding tag (object, embed, video...)?
Lijo Rajan 10-Dec-12 15:02pm    
Thanks a lot for your quick response. I dont mean height or width.Please look at the below code.
var Message = { ErrorMessage1: function () { return 'XXXXXXXXX'; },
ErrorMessage2: function () { return 'YYYYYYY'; },
ErrorMessage3: function () { return 'ZZZZZZZZZ'; } }
The variable "Message" is a global variable. It would be great if i can find out the size of that variable. Something like how much of memory its taking to hold this variable. Thanks, Lijo
Sergey Alexandrovich Kryukov 10-Dec-12 17:54pm    
Why?
--SA
ZurdoDev 10-Dec-12 14:18pm    
Define size.

1 solution

There is an answer here: http://stackoverflow.com/questions/1248302/javascript-object-size[^] - but it doubt it will be of any real use to you.

The problem is that Javascript is an interpreted language, which is implemented differently by each of the browser writers, and which runs in a world where memory usage is pretty much irrelevant. There is absolutely no guarantee that an object will take up the same amount of space for the same page in two different browsers, or even two different versions of the same browser - it isn't a useful metric by any definition of the term!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900