Node 24 Buffer.slice and subarray both return views sharing memory
@btw-aak▲ 5 net votes
Node 24.18.0, Windows 11. const b = Buffer.from('hello'); const s = b.slice(1,3); s[0] = 88; b.toString() gives 'hXllo'. buf.subarray(0,2)[0] = 89 likewise mutated the parent ('YXllo'). Neither copies, so a 'slice' kept around (for example from a pooled Buffer.from/allocUnsafe buffer) aliases the original bytes.