-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnote.txt
277 lines (152 loc) · 10.4 KB
/
note.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
ECMAScript(ES)
ECMAScript - European Computer Manufacturer Association Script Introduced Javascript in 1995
Intially Javascript named as Netscape later it ivolved through various name finally name as Javascript
ES is a standardization for Javascript
ES standardization started from 1997
ES1 - 1997
currently we are using ES6/ES7
ES6 - 2015
ES7 - 2017
Tools
Nodejs(Any Version)
Vscode here used
JSbin online ide
Browser - Edge
variable is a space in memory to reserve for something here we can store values
take care
__ numbers would not be wrapped in single or double quotes
__ string value or character must be wrapped in single or double quotes
__ if numbers are wrapped in single or double quotes if we are performing addtition instead of
operation addtition it will concatenate the values in case of integers or numbers
__ we can't use space in decalaring a variable
__ try to use camel casing in programming to maintain a standard camelcasing example(fisrtName)
if we are joining two words fisrt word should start with small letter and second word should startwith capital
letter and third word also with capital letter and the remaining all
__ we can declare a varibale only once multiple times declaration of varibales multiple times will result in syntax error
we can change value inside a variable multiple times
__ if we declare a constant don't try to change value inside the constant this will result in syntax error
__ in order to maintain standard in arithmetical operations use () brackets other wise more number will make our code complex
it will follow a operator precdence in operations
----------------------------------------------null---------------------------------------------------------------------------
if we don't intializea a value inside a variable and if we compile it we will get value is undefined
undefined means that no value is assigned to that
undefined null and zero both are different concepts in Javascript
don't try to replace undefined with zero and null its a wrong concept use each things properly
null and undefined are completely different from zero
-----------------------------------------------conditional programming--------------------------------------------------------
we need to execute certain part of statement based on certain events are called conditional programming
boolean values can have only two values mainly true and false
in Javascript if we assign a condition to a variable we can get true or false based on that condition
(
let marks = 7
let grade = (marks < 10)
console.log(grade)
)
refer 01Basics nullandbool.js
------------------------------------------------------02Basics----------------------------------------------------------------
as a first part we are familiaring if else problems
in case of Javascript if you want to declare something globally then only use var else use let
to declare variable(this will work in case of conditional statements only not in case of functions )
we have done a program named letvar.js to check that Please refer that
we can declare variable in Javascript without lets and var declaring variable in such a way is not
a good thing it is a security flaw in javascript so we should use lets var keyword in javascript to
declare a varibale refer king.js problem
------------------------------------------------console log----------------------------------------------------------------------
if we need to perform a js operation inside console command we use backquotes and $ with brackets{}
with this approach we can perform javascript operation inside thar brackets
---------------------------------------------------array-------------------------------------------------------------------------
in case of array we can change value while using constant also this because in javascript array is treated as an object in
javascript
so in array we can change value in javascript even if we are using const
using array shift we can shift an array value at index 0 or we can remove a values
as in same way using unshift we can add a value at index 0 without loosing current value at index 0
using pop operation we can delete a value in array last element is deleted we can`t make it any other element by using index
value and in the same way using push operation we insert an element as last element
middle method in javascript we can delete element using splice keyword in splice first we need to
mention where the element to be delete start .that we need to mention .how many elements to be deleted if 1 element
mention it as one and also if we need to insert any values also mention that to see the operation refer arraymethod.js
------------------------------------------------------Functions in Javascript----------------------------------------------------------
--------Intermediate Starts here----------------------------
Functions are certain action which makes our program easy mainly there are two types of Functions
Pre defined Functions function were pre written or available in the compiler
(Ex : console.log('akkku') here console.log is predefined function which print akku)
User defined functions which written by the user in javascript we can use many ways to write functions
function example
--------------------------------------|
let akku=function(){ |
|
console.log("akhil") |
console.log("binu") |
} |
akku() |
--------------------------------------|
in function if we need to use variable globally declare inside function brackets if we declare inside
curly brackets we can use that variable locally only inside that function only
function with return value in javascript
---------------------------------------|
|
let MyAdder = function(num1 , num2){ |
|
let result = num1 + num2 ; |
return result; |
} |
console.log(MyAdder(3,5)) |
|
---------------------------------------|
in return statement in function we can use print and variable directly with the help of concatenation function
below is an example we can use default values in javascript if we pass values then new values will be taken for processing
----------------------------------------------------------------------------------------------|
let guestUser = function(name = 'unName' , courseCount = 0 ){ |
|
return 'hello ' + name + ' you have enrolled in ' + courseCount + ' courses' ; |
} |
|
console.log(guestUser('akhil',3)) |
----------------------------------------------------------------------------------------------|
in forEach loop we can directly use function in inside the brackets
Functions which doesn't have name is called callback function below is example
------------------------------------------------------------|
|
let days = ['mon','tue','wed','thu','fri','sat'] |
|
days.forEach( |
function(day){ |
console.log(day); |
} |
|
) |
------output------------------------------------------------|
mon |
tue |
wed |
thu |
fri |
sat |
------------------------------------------------------------|
whats we used inside function brackets is called parameter in case of forEach loop while using
array in above similar case in can name parameter as our wish
(refer more on trello.js)---------(IMPORTANT)
(for knowing more aspects of refer forloop.js)
== ( In javascript == refers to if both sides are equal or not)
=== (in javascript === refers to memory which it stored refer equal.js in 04 Intermediate)
if we are creating two objects both are referenced two different memory locations thats if we check two objects
=== it will say that its no equal
creating objects is shown in myObject.js in 04Intermediate
as in function we can change value inside a function refer workObject.js 04Intermediate
for best of our knowledge we can write function inside an object
--------------------------------------This keyword------------------------------------------------------------------------------------
this keyword is used to refrence the entire object refer trelloV3.js in 04Intermediate to know more
we can simply say that this refers to entire properties in an object
--------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------|
proper couldn't be named in same names (IMPORTANT) |
------------------------------------------------------------------|
please note that .length is a property and not a function
refer webCheck.js for more
in js we can use many function .toFixed(number) function is used to reduce the values inside the javascript quoates
in javascript math is one of the most powerfull library
refer mdn docs and dice.js
refer trelloV4.js in 04Intermediate it contain lot of things about array in javascript
in 05 Advance first refer arrow.js thsn arrowadv.js then assignarray.js then move on to arrayarrow.js
for coercion refer 05Advance-basic coercion.js
for try and catch problem refer trycatch.js