Click here to Skip to main content
12,892,320 members (48,214 online)
Rate this:
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 7:36am
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...)?
ryanb31 10-Dec-12 14:18pm
Define size.
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

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
Top Experts
Last 24hrsThis month

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