Click here to Skip to main content
11,490,801 members (73,120 online)
Rate this: bad
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?

Posted 10-Dec-12 8:36am
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
ryanb31 at 10-Dec-12 14:18pm
Define size.

1 solution

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

Solution 1

There is an answer here:[^] - 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!

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 476
1 Andy Lanng 288
2 Sascha Lefèvre 240
3 OriginalGriff 178
4 Maciej Los 160
0 Sergey Alexandrovich Kryukov 9,713
1 OriginalGriff 8,475
2 Sascha Lefèvre 3,544
3 Maciej Los 3,106
4 Richard Deeming 2,370

Advertise | Privacy | Mobile
Web01 | 2.8.150520.1 | Last Updated 10 Dec 2012
Copyright © CodeProject, 1999-2015
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