Node.js · Middle · Question 17 of 75

What is the difference between Buffer.alloc(10) and Buffer.allocUnsafe(10)?

Explanation

Use allocUnsafe only if you immediately overwrite every byte. Otherwise you might leak sensitive data that was previously in that memory.

Further reading

Problem with a question

Node.js · Middle · question 17

Test yourself

Take the Node.js · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz