miktam / sizeof

Get size of a JavaScript object
MIT License
311 stars 45 forks source link

Size of the string and an array with the same number of chars is different. #29

Closed xtrmstep closed 5 years ago

xtrmstep commented 5 years ago

For this case `

let str = "1234";
let arr = ["1","2","3","4"];

let sizeStr = sizeof(str);
let sizeArr = sizeof(arr);

console.log(`size str: ${sizeStr} bytes`);
console.log(`size arr: ${sizeArr} bytes`);

` Values of sizeStr and sizeArr are different (8 vs 16). They should be equal.