找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 62|回复: 0

Possible to reduce

[复制链接]

1

主题

0

回帖

5

积分

新手上路

积分
5
发表于 2023-12-21 18:50:31 | 显示全部楼层 |阅读模式
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.

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|爱零愛菁 ( 粤ICP备2022038107号 )

GMT+8, 2025-1-24 10:45 , Processed in 0.014849 second(s), 20 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表