-
Notifications
You must be signed in to change notification settings - Fork 0
/
variable.js
72 lines (59 loc) · 2.05 KB
/
variable.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
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
/*
------------------
i) VARIABLE
-------------------
1. What is JavaScript?
=> JavaScript is a high level scripting language.
Also known as interpreted, multi-paradigm, dynamic typing, prototype based object-oriented programming language.
2. How does JS Works?
=> JavaScript is an interpreted language that means it gets executed in line by line manner which means the JavaScript engine converts the Js code line by line and runs in the same manner instead of converting the whole program once.
3. What is Variable?
=> A JavaScript variable is simply a name of storage location.
4. Declare a variable
=> var name = "Jumman" ;
5. Types of Variable?
=> There are three types of variables: i) number ii) string iii) boolean
How can you find out type of a variable?
=> console.log(typeof(variable name));
6. Primitive and non-primitive data types!
=> primitive data types: There are seven primitive data type: 1)Number, 2)String, 3)Boolean, 4)Undefined,
5)Null, 6)bigint, 7)Symbol.
Non-primitive data type: 1) object
7. Naming Convention of JS variables
=> 1) var 2) name 3) = 4)data 5) ;
8. Math Operation +, -, *, /, %
=>
------------ + -------------
var applePrice = 450;
var bananaPrice = 200;
console.log(applePrice + bananaPrice);
Result: 650
------------ - -------------
var applePrice = 450;
var bananaPrice = 200;
console.log(applePrice - bananaPrice);
Result: 250
------------ * -------------
var appleWhite = 450;
var applePriceKg= 10;
console.log(applePrice * bananaPrice);
Result: 4500
------------ / -------------
var banana = 10;
var person = 5;
console.log(banana / person);
Result: 2
------------ % -------------
var banana = 11;
var person = 5;
console.log(banana % person);
Result: 1
9. Short hand: +=, -=, *=, /=
=> += increase, -= decrease, *= multiple, /= divided
10. ++, --
=> ++ increase one, -- decrease one
11. parseInt, ParseFloat
=> ParseInt for string number type to number and ParseFloat for integer decimal number to decimal number.
12. toFixed
=> Use to limit the digit of decimals
*/