This content originally appeared on DEV Community and was authored by DevCronin
Welcome to Level up with JavaScript
In this blog series tutorial, you will be introduced to some of the basic JavaScript programming concepts.
This is geared toward beginners and anyone looking to refresh their knowledge.
To get started, here is an example of a basic JavaScript program called "Hello World".
function greetMe(yourName) {
alert("Hello " + yourName);
}
greetMe("Zach");
"Hello Zach"
Now that you have seen what JavaScript is and an example of how to write a simple program, let's level up!
Comments, Declaring Variables, Storing, Assigning, and Initializing Values
Comments
Comments are notes about your code for you or other developers.
JavaScript will ignore everything after a double forward slash for in-line, and between a forward slash + asterisk for multiline.
// This is an inline comment
/* This is a
multi-line comment */
Declaring Variables
Variables allow computers to store and use data.
JavaScript uses these eight data types: undefined, null, boolean, string, symbol, bigint, number, and object.
These variables must be declared by the "var", "let", or "const" keyword.
Variables can have numbers, letters, dollar signs, or underscores. They cannot contain spaces or start with numbers.
Semicolons are used at the end of statements. They are sometimes optional in JavaScript because of automatic semicolon insertion.
However, I would advise always including them until you are more experienced.
var level;
Storing Values
Values can be stored as a variable with the assignment operator (=).
In this example, I declare the variable "level" and set it to the value 1.
Now each time "level" appears in the code, the program will treat it as 1.
var level;
level = 1;
Assigning Values
Next, the assignment operator can be used to assign the same value from the previous variable to another variable.
With the below example, now JavaScript_level and level are both the same value of 1.
var level;
level = 1;
var JavaScript_level;
JavaScript_level = level;
Initializing Values
Initialize allows us to assign an initial value to a variable as it is declared.
This is done on the same line that the variable is created.
var level = 1;
Thank you for reading my blog! This is the first of my series on JavaScript so if you would like to read more, please follow!
...
Support and Buy me a Coffee
This content originally appeared on DEV Community and was authored by DevCronin
DevCronin | Sciencx (2021-08-14T23:12:07+00:00) Level Up with JavaScript. Retrieved from https://www.scien.cx/2021/08/14/level-up-with-javascript/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.