that I always come across
If you are just beginning in JS, only some parts of The Modern JavaScript tutorial are required:
As well as 2 primers on events, and Websocket
Now you’re ready to learn using the only valid discord.js bot tutorial, you’re welcome.
Make sure you are at least intermediate in JavaScript (see Resources). Learn some HTML/CSS.
Expand your skills with network, SEO, accessibility, APIs, etc….
Feel free to contribute any resources
React. Don’t learn Angular if you don’t have to.
Until React Suspense is a thing, use React Async.
To learn the trade for future jobs? It depends entirely on your market. If you don’t know, I would go for React this time, as it’s the least opinionated.
But look the stack used by companies in the area you want to apply, this will be a far better gauge.
JS.info is currently the best online resource out there to learn modern JS and some frontend, but mandatory entries are mixed with optional knowledge. Here’s what you should take out of js.info
Even if you won’t work with the browser, there are concepts revelant for all environments
If browser environment: 5.2 Scripts: async, defer see related correct use of JS in the browser; the entirety of Part 2
WE ARE NOT LAWYERS
However, to get a feeling of what you can and cannot do with a third party program, it’s published with a certain license
https://tldrlegal.com/
To find out your own https://choosealicense.com/
You’re on Windows and a package that has a build step (node-canvas
, bson
, sqlite3
, etc…) outputs an error with a trace like
node-pre-gyp ERR! build error
?
You need specific build tools on Windows that don’t come natively and that node-gyp failed to install by itself.
Here are the quick steps to solve this:
npm i -g --production windows-build-tools --vs2015
npm config set msvs_version 2015
where python
npm config set python C:\\Python39\\python.exe
(or your actual path, you get it)Only do these steps this one time and you shouldn’t have anymore problems
Relevant info on a package page https://imgur.com/PQJiC0G
Check if its license matches your needs (see What license?)
A small list of bad packages and their alternatives
request
. Use node-fetch
. Since node v18, fetch is nativesqlite
, sqlite3
. Use better-sqlite3
mysql
. Use mysql2
(via mysql2/promise
) or knex
(WIP) By example
function fetchJSON (url) {
return fetch(url).then(response => response.json());
}
function updatePara (url) {
fetchJSON(url).then(data => {
const { title, text } = data;
paragraph.dataset.title = title;
paragraph.textContent = text;
})
.catch(log);
}
async function fetchJSON (url) {
const response = await fetch(url);
return response.json();
}
async function updatePara (url) { // You obviously NEED the async keyword
try {
const { title, text } = await fetchJSON(url);
paragraph.dataset.title = title;
paragraph.textContent = text;
} catch (err) {
log(err);
}
}
https://2ality.com/2016/10/async-function-tips.html
var
was the old way of declaring variables. Its features can and do lead to confusion, so just don’t use it.
ES6 introduced const
and let
. They are the sane way of declaring variables.
Your editor will tell you are writing code that cannot run, so your code will become less ugly by force.
As to which between const
and let
? Use const
always. Refer to best practices.
By using const
, you’re stating: “This variable will only allowed to be an Enum (constant string, magic number, config boolean) or a collection (array, object, set, map) and nothing else, my linter will tell me if I screw up when I use it in any other way”.
Moreover, if you default to const
, then let
conveys more meaning: “This variable MUST change in the flow of my program (concatenate strings, add numbers, toggle a boolean dynamically, allow this object to be emptied again or extending it via spread)”.
An added benefit of const
is that let
doesn’t allow for constant folding.