To understand monkey patching in Javascript
<p>I am trying to understand the concept behind how monkey-patch works in JavaScript?</p>

<p>I've gone through too many examples but couldn't able to understand</p>

<p><strong><em>For example - Monkey patching the dispatch function in Redux</em></strong></p>

<pre><code>let next = store.dispatch
store.dispatch = function dispatchAndLog(action) {
  console.log('dispatching', action)
  let result = next(action)
  console.log('next state', store.getState())
  return result
}
</code></pre>

<p>Source: <a href="http://redux.js.org/docs/advanced/Middleware.html#attempt-3-monkeypatching-dispatch" rel="nofollow noreferrer">http://redux.js.org/docs/advanced/Middleware.html#attempt-3-monkeypatching-dispatch</a></p>

<blockquote>
  <p>Can anyone please explain monkey patching in simple terms and example</p>
</blockquote>

<p>And which is the best scenarios to use it?</p>

<p>Thanks.</p>