The result may be disturbed by even a lack of network connection. Any methods that query or manipulate the DOM will also be impure functions . There is no guarantee that the DOM structure will never change. Also all functions that manipulate files on disk will be impure functions. function getRandom number return Math.
random function getISODate Date return new Date async function getUsers Promise const response Response await fetch 'https test users' return responsn function getUserIdElement HTMLElement | null return documentge Phone Number List tElementById ' foo' function writeFile void writeFileSync 'fotxt' 'bar' Summary In conclusion I think it is worth adding that using the impure function is not clearly bad. As in many other aspects "it depends" . Many of the examples of functions presented are imprecise by their nature and their use is normal.
However I would like to emphasize that if it is the impure function to pure form it will usually be worth doing so. The question about pure functions is one of the questions included in my e book Junior JavaScript Developer Recruitment Questions . I encourage you to read the additional materials leave a comment and share this post! Sources and additional materials Pure Functions in JavaScript SQL Query Builder for Javascript fix security avoid password leaks on query logs Knex should use config copy while trimming password field Breaking change frozen config What is Memoization How and When to.