Node.js · Buffers · Junior · Comparison
Buffer.alloc vs Buffer.allocUnsafe vs Buffer.from — security angle?
Short Interview Answer
alloc zero-fills; allocUnsafe may contain old memory (leak risk); from copies/interprets input.
Detailed Explanation
Never use allocUnsafe for buffers that might be returned to users. Prefer alloc/from. This is a classic security interview question.
Common Mistake
Using allocUnsafe for response bodies 'for speed'.