Skip to content

Weird Behaviour with arrays #87

@geo-systems

Description

@geo-systems

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?

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions