Can someone help me to understand, What is difference between filename.js and ./filename.js
(note: While we include in html or any js file)
Can someone help me to understand, What is difference between filename.js and ./filename.js
(note: While we include in html or any js file)
As far as I know, there are no differences: both point to the file named filename.js in the current directory.
filename.js refers to a js while residing in the current directory. ./filename.js means that in the current directory a filename.js resides.
So, basically there is no difference but when including, to give relative path you must use "./filnemae.js".
Path can be relative or absolute. (./) means current directory, so if you are in a directory called test and you use ./page.js it means the full path is test/page.js
The second example page.js searches for a page with that name in the current directory.
Basically there are the same as long as you are referring to the file in same folder(test).
there's no use is stating "./filename.js"
over "filename.js"
. It's a forgiven coding mistake more than a convention or a sort of standard. They will both create a (relative) path which will point to the [current directory]"filename.js".
I guess, what you are looking for is the "../filename.js"
r.p. (relative path) syntax.
This is a shorthand and a correct syntax for r.p., pointing to the parent folder of the current path.
Let's say, your current path is:
"domain/home/page1/index.html"
adding "../filename.js"
will produce:
"domain/home/filename.js"
whereas, "filename.js"
will produce:
"domain/home/page1/filename.js"
.