what is the difference between import and const and which is preferred in commonjs : <p>I have noticed a bit of switching between using const and import for referencing libraries in node.js applications using es6 syntax with Babel.</p>

<p>What is the preferred method and what is the difference between using const and import? Assuming you may be importing the same library in many files/components.</p>

<p><strong>const</strong></p>

<pre><code>const React = require('react')
</code></pre>

<p><strong>import</strong></p>

<pre><code>import React from 'react'
</code></pre>

<p>Here are the definitions of each but I am still not sure which to use.</p>

<p><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import">import</a></p>

<p>The import statement is used to import functions, objects or primitives that have been exported from an external module, another script, etc.</p>

<p><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const">const</a></p>

<p>The const declaration creates a read-only reference to a value. It does not mean the value it holds is immutable, just that the variable identifier cannot be reassigned.</p>
