Recently, while engaging in a online discussion, a question caught my attention.
Sometimes i see symbols like “@“ or “*” or “” or “^” or “~”
And I don't know what are they used in ..?!
I wait some time, but I saw that anyone answer the question, I just saw one intention to doit that was a link of a blog post that not track the entire question. So I take the time to answer it, and after doing it I just ask to myself: Why do not create post of this answer?
So here I am, maybe for expert it sounds easy-peasy or like a piece of cake but for the most beginers that try to find some guide in the masive world of things it could be helpful.
All this symbols in the question are for different things.
@
Let start with the at symbol (@). As the question was asked about a js file, so I could say that in JS projects is used to have a convenient way to access to root folder of your app.
Instead of doing ../../../../../../../../../
, accesing from the root could be shorted but the most important benefit is that alias is the same for every file. So moving file dont need update imports.
For more information check the rollup alias plugin
*, **, ^
The asterisks (* or **), carret(^), is more a OS thing or to be specific is part of glob (https://en.wikipedia.org/wiki/Glob_(programming)).
In general it means the following:
- * (any file)
- ** (any folder)
- ^ (exclude this, but I think that you need some extension of glob or something like that. check this discussion about it)
~
The tilde symbol (~) is for user directory. In linux you could go to your user directory using "cd ~" any time. Some any path written with than means that is searching the path starting form user directory, it an alias already provided by the OS. Check this link
I hope this explanation was helpful to you, because I really enjoy wrinting this answer.
See you in the next one.
Top comments (0)