What is the difference between using ./ and directly writing a directory or file name when working with paths.
Suppose I have the following simple structure:
project
│ index.html
│
└───pages
│ │ file1.html
│ │ file2.html
│ │
│ └───about
│ │ file3.html
│ │ file4.html
If I am say in file1.html
what is the difference between writing the link is the following ways?
<a href="./about/file3.html">Link</a>
vs.
<a href="about/file3.html">Link</a>
Important
I know what ./
means!
I just want to know if there is a practical difference & advantage/disadvantage
On the web, as far as I know, the two are functionally equivalent.
However, inside a Node.js application, the ./
differentiates local files from library files (ie. files coming from NPM/node_modules
).
In other words:
import Foo from 'foo';
imports the Foo
variable from the library called "foo", in node_modules
, while:
import Foo from './foo'
would instead import Foo
from a file called foo.js
in the same directory.