-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIntro.js
More file actions
88 lines (71 loc) · 2.3 KB
/
Intro.js
File metadata and controls
88 lines (71 loc) · 2.3 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/* This is a comment
that spans multiple lines
*/
// This is a single-line comment
var first = 0;
var First = 0;
var str = "Hello World!"; // String variable
var bool = true; // Boolean variable
var num = 42; // Number variable
var arr = [1, 2, 3]; // Array variable
var obj = { name: "John", age: 30 }; // Object variable
var func = function() { // Function variable
console.log("Hello from function!");
};
var nullVar = null; // Null variable
var num;
console.log(first,obj); // Output: 0 { name: "John", age: 30 }
console.log(str); // Output: Hello World!
// == Equality operator
// === Strict equality operator
// != Inequality operator
// !== Strict inequality operator
// > Greater than operator
// < Less than operator
// >= Greater than or equal to operator
// <= Less than or equal to operator
// && Logical AND operator
// || Logical OR operator
// ! Logical NOT operator
// ++ Increment operator
// -- Decrement operator
// += Addition assignment operator
// -= Subtraction assignment operator
// *= Multiplication assignment operator
// /= Division assignment operator
// %= Modulus assignment operator
// ** Exponentiation operator
// << Left shift operator
// >> Right shift operator
// >>> Unsigned right shift operator
// & Bitwise AND operator
// | Bitwise OR operator
// ^ Bitwise XOR operator
// ~ Bitwise NOT operator
const PI=3.14; // Constant variable
const E=2.71; // Constant variable
const GRAVITY=9.81; // Constant variable
const SPEED_OF_LIGHT=299792458; // Constant variable
//
//PI = 3067. // Error: Assignment to constant variable.
// E = 2.72; // Error: Assignment to constant variable.
// GRAVITY = 9.8; // Error: Assignment to constant variable.
// SPEED_OF_LIGHT = 300000000; // Error: Assignment to constant variable.
console.log(PI); // Output: Hello World!
var car = {
make: "Toyota",
model: "Camry",
year: 2020,
start: function() {
console.log("Car started!");
}
};
car.start(); // Output: Car started!
var person = {
name: "John",
age: 30,
greet: function() {
console.log("Hello, my name is " + this.name);
}
};
person.greet(); // Output: Hello, my name is John