Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript size of variable in kb

function roughSizeOfObject( object ) {

    var objectList = [];

    var recurse = function( value )
    {
        var bytes = 0;

        if ( typeof value === 'boolean' ) {
            bytes = 4;
        }
        else if ( typeof value === 'string' ) {
            bytes = value.length * 2;
        }
        else if ( typeof value === 'number' ) {
            bytes = 8;
        }
        else if
        (
            typeof value === 'object'
            && objectList.indexOf( value ) === -1
        )
        {
            objectList[ objectList.length ] = value;

            for( i in value ) {
                bytes+= 8; // an assumed existence overhead
                bytes+= recurse( value[i] )
            }
        }

        return bytes;
    }

    return recurse( object );
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: discord js sending a message to a specific channel 
Javascript :: change icon sapui5 
Javascript :: quicksettins.js 
Javascript :: router class in backbone 
Javascript :: Sailsdock 
Javascript :: node:internal/modules/cjs/loader:936 throw err; ^ 
Javascript :: js get element by class 
Javascript :: tooltip.js cdn 
Javascript :: call function after 2 seconds javascript 
Javascript :: javascript get clipboard contents 
Javascript :: how to add event listener to iframe 
Javascript :: create hash in node js 
Javascript :: how to get id from url in javascript 
Javascript :: style display block js 
Javascript :: javascript find unique values in array 
Javascript :: easyui datagrid double click cell 
Javascript :: javascript get label value 
Javascript :: jspdf line 
Javascript :: how to filter an array of objects in javascript 
Javascript :: split integer into digits javascript 
Javascript :: How find a specific character in js 
Javascript :: delete attribute javascript 
Javascript :: clear input from file vue 
Javascript :: video play on page load 
Javascript :: react map 
Javascript :: how to read a firebase txt file 
Javascript :: javascript absolute import 
Javascript :: faker npm 
Javascript :: bootstrab close modal 
Javascript :: Check your Homestead.yaml (or Homestead.json) file, the path to your private key does not exist. 
ADD CONTENT
Topic
Content
Source link
Name
2+8 =