JS: iterating over result of getElementsByClassName using Array.forEach

No. As specified in DOM4, it’s an HTMLCollection (in modern browsers, at least. Older browsers returned a NodeList). In all modern browsers (pretty much anything other IE <= 8), you can call Array’s forEach method, passing it the list of elements (be it HTMLCollection or NodeList) as the this value: If you’re in the happy position of being able to use ES6 (i.e. you can safely … Read more

How to get unique values in an array

Since I went on about it in the comments for @Rocket’s answer, I may as well provide an example that uses no libraries. This requires two new prototype functions, contains and unique For more reliability, you can replace contains with MDN’s indexOf shim and check if each element’s indexOf is equal to -1: documentation

ReactJS – .JS vs .JSX

There is none when it comes to file extensions. Your bundler/transpiler/whatever takes care of resolving what type of file contents there is. There are however some other considerations when deciding what to put into a .js or a .jsx file type. Since JSX isn’t standard JavaScript one could argue that anything that is not “plain” JavaScript should go into … Read more