- Adding interaction to webpages
- Creating web and mobile apps
- Building web servers
- Developing games
Once you are in your compiler, you’ll see a blank canvas or maybe some numbers and welcome text. If you’re using Programiz, you’ll see that the “main.js” file initializes when you access the webpage, which includes a description of the compiler and some code.
The description is preceded by two forward slashes,
// This is my first comment!
Next, you may see a line of code that starts with console.log. The console.log method outputs, or logs, a message to the web console. This is how you can print out text to the user. In your program, try printing out “Hello World!” It’ll look like this:
|String||represents textual data||
|Number||an integer or a floating-point number||
|BigInt||an integer with arbitrary precision||
|Boolean||any of two values: true or false||
|Undefined||a data type whose variable is not initialized||
|Null||denotes a null value||
|Object||key-value pairs of collection of data||
var – var x = 123;
let – let x = 5;
const price = 3;
All variables must be identified with unique names called “identifiers.” They can be short names like
var x or more descriptive like
const price. The identifiers can contain letters, digits, underscores, and dollar signs, but they must always begin with a letter. Identifiers are also case-sensitive.
What are the differences of the
var has been around since the beginning and can be re-declared and updated.
let has since become the preference for variable declaration, as it’s an improvement upon
var. It can be updated but not re-declared.
const is named as such because it maintains constant values. It cannot be updated or re-declared, which is great for data that cannot change.
Try writing your own variable. For example:
let myFirstVar = “This is my first variable!”;
And then print it out!
What do you see in the console?
|Comparison (relational) operators||
Arithmetic operators help to perform basic math with code.
What do you think the following will print?
Next week, we’ll learn about some of the other operators and how to use them.