Why there is a difference of usage between the import statement and the require statement in different parts of the project directories using these frameworks, answered.
Why there is a difference of usage between the import
statement and the require
statement in different parts of the project directories using these frameworks, answered.
I had always thought that JavaScript import
and require
statements to be more or less the same. When you want to use other components and functionalities from different files or modules, you would either import
or require
it to the file you are working on. The only difference between import
and require
statements, I thought, was due to the former being the ‘newer’ version of the latter. Nothing else.
My preconception was proved wrong when working on a project using the Gatsby framework. I had no trouble using either import
or require
statements when writing codes inside the src
directory. However, when it came to configuring the app on files that sits on the root directory, errors started to emerge when using the import
statement. After digging into the issue, here is what I found out.
The main goal of this blog is to explain the “Architecture of Nodejs” and to know how the Nodejs works behind the scenes. Generally, most of the server-side languages, like PHP, ASP.NET, Ruby, and including Nodejs follows multi-threaded architecture. That means for each client-side request initiates a new thread or even a new process.
Every function created with the function keyword or with the method shorthand has its own “this”, and it generally binds to “who” called it. Arrow functions don’t bind “this” to anything, the “this” inside depends on the surrounding context
Looking to build dynamic, extensively featured, and full-fledged web applications? **[Hire NodeJs Developer](https://hourlydeveloper.io/hire-dedicated-node-js-developer/ "Hire NodeJs Developer")** to create a real-time, faster, and scalable...
Import & export of ES6 modules in JavaScript explained. Using the browser, compiler and even Node.js
Learn what ES6 is, what ECMAScript is, and why it is important to learn for writing modern JavaScript.