Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Javascript
Hi All,
 
Can anyone please tell me how to find out the size of an object in javascript?
 
Thanks,
Lijo
Posted 10-Dec-12 8:36am
Comments
Zoltán Zörgő at 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 at 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 at 10-Dec-12 17:54pm
   
Why?
--SA
ryanb31 at 10-Dec-12 14:18pm
   
Define size.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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!
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 277
1 Maciej Los 230
2 BillWoodruff 205
3 Sergey Alexandrovich Kryukov 195
4 DamithSL 165
0 OriginalGriff 5,130
1 DamithSL 4,157
2 Maciej Los 3,650
3 Kornfeld Eliyahu Peter 3,460
4 Sergey Alexandrovich Kryukov 2,811


Advertise | Privacy | Mobile
Web02 | 2.8.141216.1 | Last Updated 10 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100