What is a runtime?
npm which allows users to install modules. Other languages also have package managers. For example, Python uses PIP, Ruby has RubyGems, and Rust has Cargo.
Node.js is the most popular in the US. Over 6.3 million websites based in the US use it. Out of over 63,000 checked websites in the US, more than 37,000 completely run on Node. Massive corporations such as Google, Spotify, etc. run on Node.js.
Syntax are writing rules that you have to follow while writing code. For example, in English, you need to remember to have periods at the end of sentences, and you also need to remember to indent your line at the beginning of a new paragraph.
- Fixed values
- Variable values
Fixed values are called literals and variable values are called variables.
The two most important syntax rules for fixed values are:
Numbers are written with or without decimals
Strings are text, written with double or single quotes.
const to declare variables.
Note: The keyword
var isn't very used anymore after the introduction to newer ES versions.
An equal sign is used to assign values to variables. In the following example,
x is defined as a variable. Then,
x is assigned the value
let x; x = 6;
Note: Not all variable types allow you to reassign variables. This same example won't work for the
const variable, as it stands for constants. Variables will be explained more thoroughly in the next lesson.
/) to compute values:
console.log(5 + 10 * 10)
=) to assign values to variables.
// or between
*/ is treated as a comment. Comments are ignored, and therefore will not be executed.
let x = 5; // This line IS executed. // x += 1; This line is NOT executed.
- A letter (A-Z or a-z)
- A dollar sign ($)
- Or an underscore (_)
Subsequent characters may be letters, digits, underscores, or dollar signs.
Note: Numbers are not allowed as the first character in identifiers.
abc are two entirely different variables:
let ABC = "ABC"; let abc = "abc"; console.log(ABC); // --> returns "ABC" console.log(abc); // --> returns "abc"
Programmers have used many ways of joining multiple words into one variable name:
- first-name, last-name, date-of-birth
- first_name, last_name, date_of_birth
- Lower Camel Case:
- firstName, lastName, dateOfBirth
I recommend using camel case as it's widely used and the most comfortable (it is also prettier).
Always know, the homework assignments are only there to improve your skills and to test what you know. They are not required.
Other than that, have a wonderful day and see you later!