-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasic.js
47 lines (29 loc) · 1.19 KB
/
basic.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//This is a tutorial for beginner learning javascript with sample code
//This is a javascript comment , comment are the way you write instruction to your code without affect the code
/*This is a multi line comment
Multi line comment 2
*/
//This is how you declare a variable for your project:
var variables = "this is a variable"; //Put the semicolon at the end because is necessary
/*Code breakdown
*The variable "variables" will have the value of "this is a variable"
*/
//This is a way to print the value of the 'variables' variable:
console.log(variables);
//The output will be : this is a variable
//you can use let and const for declaring variable too
//example:
const a = 1;
//or :
let b = 5;
//danger note: let and const cannot be redeclare
//error example:
let x = "x1";
let x = 0;
// Error message : SyntaxError: 'x' has already been declared
// There are a way to declare multiple value in the same variable
// Example:
var multipleVar = ["variable1" , "variable2" , "variable3"];
console.log(multipleVar); // this will print out : variables1,variable2,variable3
//you can even declare an array using the Javascript keyword "new"
const Name = new Array("Peter", "Paul", "Bob");