Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

index.js vs main.js

It's pretty simple!

If your application is to be used in other applications: index.js

If your application is NOT to be used in other applications: server.js or app.js

As stated earlier the reasons being, when invoking npm start, if not defined in package.json, looks automatically for server.js. And when including another module into your application, it looks for index.js.

Extra: I also tend to only use index.js as a file name when this is automatically found somehow. This makes me aware if the file is invoked directly or indirectly.

When using npm init it makes the default index.js.
Comment

PREVIOUS NEXT
Code Example
Javascript :: js vanilla when i remove one object it removes all of them 
Javascript :: javascript add quote comma 
Javascript :: json_encode escape 
Javascript :: search filter in react js using api function components 
Javascript :: jquery all elements whose id contains 
Javascript :: vscode default indent type 
Javascript :: documentready 
Javascript :: add favicon to next js static site 
Javascript :: datatable columns with nullable fields ajax 
Javascript :: ffmpeg thumbnail generator 
Javascript :: string to char array in javascript 
Javascript :: javascript push in specific index 
Javascript :: reactjs firebase where map value 
Javascript :: change header background color on scroll css 
Javascript :: javascript div id add class 
Javascript :: javascript for each key in object 
Javascript :: retrieve object array value based on key 
Javascript :: angular string to number 
Javascript :: uuid v4 
Javascript :: windows.load with settimeout 
Javascript :: mysql json change key 
Javascript :: nodejs get response time 
Javascript :: useref object is possibly null 
Javascript :: filter special characters javascript 
Javascript :: clear screen in js 
Javascript :: require() of ES modules is not supported when importing node-fetch 
Javascript :: timestamp js 
Javascript :: how to check if the user is in a certain guild in discord 
Javascript :: regex for 4 digit number javascript 
Javascript :: how to define emojis from your server in discord.js 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =