title: A plain JavaScript way to decode HTML entities, works on both browsers and Node
body: <p>How to decode HTML entities like <code>&amp;nbsp;</code> <code>&amp;#39;</code> to its original character?</p>
  
  <p>In browsers we can create a DOM to do the trick (<a href="https://stackoverflow.com/questions/1147359/how-to-decode-html-entities-using-jquery/1395954#1395954">see here</a>) or we can use some libraries like <a href="https://github.com/mathiasbynens/he" rel="noreferrer">he</a></p>
  
  <p>In NodeJS we can use some third party lib like <a href="https://www.npmjs.com/package/html-entities" rel="noreferrer">html-entities</a></p>
  
  <p>What if we want to use plain JavaScript to do the job?</p>
  
  <p>There are many similar questions and useful answers in stackoverflow but I can't find a way works both on browsers and Node.js. So I'd like to share my opinion.</p>
  
  <p>I have posted my opinion as an answer below. I hope it can be a helping hand for someone. :)</p>