I'm on Node JS 18.12.1 and I'm seeing the following behaviour:
const sizeof = require('object-sizeof')
> sizeof(["a","b","c","d","e"])
21
> sizeof("abcde")
20
> sizeof(["abcde"])
9
Why is an array of a string smaller than the string itself?
Why is an array of letters 1 byte bigger than the string? Shouldn't they be the same? Or may be the array is slightly bigger due to some reference?
I'm on Node JS 18.12.1 and I'm seeing the following behaviour:
Why is an array of a string smaller than the string itself?
Why is an array of letters 1 byte bigger than the string? Shouldn't they be the same? Or may be the array is slightly bigger due to some reference?