bun
bun copied to clipboard
`console.log()` doesn't work as in node/chrome when trying to log an array with an added custom property
const arr = ['a', 'b', 'c'];
arr['five'] = 5
console.log(arr)
Above program if run with node returns:
[ 'a', 'b', 'c', five: 5 ]
With bun
, it returns:
[ "a", "b", "c" ]
Was going through a course on ExecuteProgram.com and they had it as one of their lessons to teach that arrays in JS are also objects.
Actually in safari if you run above, it will return what bun
returns but chrome will return what node
does. This makes sense given how zig is built on JavaScriptCore. Just found it interesting. I guess this can be closed. JavaScriptCore probably chose to do it this way for perf reasons as no sane person would modify arrays with custom properties.
I guess it's more logic, cause five
is not an entry like a
or b
, it's a new prop added to arr
.
Yea going to close this as bun is using console.log() from JavaScriptCore so it's a question to them rather than bun.
bun implements console.log -- it's a bug in bun's implementation that it doesn't look at array properties
it's a bug in bun's implementation that it doesn't look at array properties
But if you run above code snippet in safari console, you also won't see properties.
