-
Notifications
You must be signed in to change notification settings - Fork 0
/
notes.txt
119 lines (117 loc) · 3.1 KB
/
notes.txt
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
OOPS: Object Oriented Programming
//javascript has inherited some features from java
//main pillar of java
//encapsulation , inheritance , polymorphism
------------------------
//encapsulation:hiding the implementation details.In which one thing is included with
other thing so that inclusive things will not appear.
example: whatsapp
---------------------
//inheritance: a parent-child relationship, in which the class takes all the
characteristics of parent class.(child==>inherits==>parents)
example: genes/dna
-----------
//polymorphism: a way to achieve a single action in different ways.
example: myself
------------
//classes and objects
//methods
//accessing
------------------------
class: it is a collection of properties , methods and objects.
. classes are generally defined by using the class keyword.
syntax:
class Classname{
//properties
//methods
//objects
}
example:
class Movie{
//rating , review , actor , actress, director , music director , genre
}
-----------------------
Object:Object is called as the real time entity.(touch and feel)
.objects are specific to the class
syntax:
var objectname = new Classname();
new - new is a keyword used to create instance of an object.
-----------------------
constructor: to store value inside the objects.
this: it is the temporary keyword which is pointing to the freshly created objects.
------------------------------
example: car
class Car{
constructor(brand ,color){
this.brand = brand; // key = value
this.color = color;
}
printcolor(){
return this.color;
}
}
var test = new Car("Audi", "black");
console.log(`the color of my car is ${test.color}`);
----------------------------------------
//task :
class ==> person
properties = (name , age , salary , gender)
-----------------------------------
methods: functions
printcolor(){
return this.color;
}
example:
class Car {
constructor(brand, color) {
this.brand = brand; // key = value
this.color = color;
}
printcolor(str) {
return str + this.color;
}
}
var test = new Car("Audi", "black");
var result = test.printcolor("the color of my car is ");
console.log(result);
-----------------------------------------------
Arrow:
var sum = (a,b)=>a*b
console.log(sum(2,3))
------------------------------------------------------
//normal function
function sum (a,b) {
return a*b
}
console.log(sum(2,3))
---------------------------------------------------
//annonumous function
var sum= function (a,b) {
return a*b
}
console.log(sum(2,3))
-------------------------------------------------
//IIFE:-()()
(function(){
console.log("this is IIFE")
})()
------------------------------------------
//with parameter
(function(name){
console.log(name);
})("Rupan")
---------------------------------------
//IIFE:- with return :
(function(name){
return name
})("Rupan")
--------------------------------------
arrow with return:-
let sum =(a,b)=>{
var result = 100;
var total = result+a+b
return total
}
console.log(sum(100,50))
console.log(sum(56,200))
--------------------------------------------------------