0 votes
in JavaScript by
What are the possible side-effects in javascript?

1 Answer

0 votes
by
  1. A side effect is the modification of the state through the invocation of a function or expression. These side effects make our function impure by default. Below are some side effects which make function impure,

  • Making an HTTP request. Asynchronous functions such as fetch and promise are impure.
  • DOM manipulations
  • Mutating the input data
  • Printing to a screen or console: For example, console.log() and alert()
  • Fetching the current time
  • Math.random() calls: Modifies the internal state of Math object

Related questions

0 votes
asked May 27, 2019 in Other by anonymous
0 votes
asked Oct 24, 2023 in JavaScript by DavidAnderson
...