Skip to content

Commit 9be4b9d

Browse files
Update README.md
1 parent bef3f5d commit 9be4b9d

1 file changed

Lines changed: 102 additions & 3 deletions

File tree

README.md

Lines changed: 102 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,7 @@ ECMA was created to standardize JavaScript to help foster multiple independent
131131
The full form of ECMA is European Computer Manufacturer's Association.A standard for scripting languages like JavaScript, JScript is ECMAScript.
132132

133133
Here NodeJS follow the ECMA standard, here we are going to dicuss about Const, Let and class.
134-
135-
Unlike variables declared with var that are function-scoped, variables declared with let are block-scoped: they only exist in the block they are defined in.
134+
> <b>let :</b> Unlike variables declared with var that are function-scoped, variables declared with let are block-scoped: they only exist in the block they are defined in.
136135
137136
```ruby
138137
var a = 20
@@ -152,7 +151,7 @@ var v = () => {
152151
v();
153152

154153
```
155-
Diffrence in Var and Let
154+
Difference in Var and Let
156155

157156

158157
|Var | let |
@@ -161,6 +160,106 @@ Diffrence in Var and Let
161160
|var variables are added to the global object as properties. The global object is window on the web browser and global on Node.js: |However, the let variables are not added to the global object|
162161
|The var keyword allows you to redeclare a variable without any issue.| If you redeclare a variable with the let keyword, you will get an error|
163162

163+
164+
> <b>Const :</b> Variables defined with const behave like let variables, except they cannot be reassigned. <br />
165+
166+
If we assign a primitive value to a constant, we cannot change the primitive value:
167+
168+
169+
```ruby
170+
const a = 30;
171+
//a = 40; // you can not assign the a to another value
172+
173+
console.log(a);
174+
175+
```
176+
177+
You can change the properties of a constant object:
178+
179+
```ruby
180+
181+
// but if you defined the object and want to change the value of it tha you can do that
182+
183+
const obj = {name : "satya", phoneNo : 1234567890, email : "Test@gmail.com"}
184+
185+
console.log(obj);
186+
187+
obj.age = 20;
188+
console.log(obj);
189+
190+
obj.phoneNo = 1234512345;
191+
console.log(obj);
192+
```
193+
> <b>Class :</b> Its type of function, but instead of using function keyword to initiate it, here use the keyword class, and the properties are assigned inside a constructor() method. <br />
194+
195+
```ruby
196+
class TestUserClass
197+
{
198+
constructor()
199+
{
200+
this.name = "Satya first ";
201+
this.phoneNumber = "6776777"
202+
}
203+
204+
getName()
205+
{
206+
//console.log(name); // this will give error to access any of the class values you need to use thi.
207+
console.log(this.name);
208+
this.age = 12
209+
return this.name;
210+
}
211+
212+
getAge()
213+
{
214+
return this.age;
215+
}
216+
}
217+
218+
219+
var tc = new TestUserClass();
220+
//tc.getName();
221+
console.log(tc.getAge()); // you need to call the Get name first as the Age setting their.
222+
```
223+
224+
## Day 5 - Prototype
225+
226+
In the previous chapter we learned how to use an object constructor.
227+
228+
Sometimes you want to add new properties (or methods) to all existing objects of a given type.
229+
Sometimes you want to add new properties (or methods) to an object constructor.
230+
231+
Prototype property in Javascript allows you to add new properties to object constructors.
232+
233+
``` ruby
234+
// prototype usese to extend the functionalty of exiting function.
235+
236+
var Employee = function()
237+
{
238+
this.name = "Satya";
239+
this.age = 30;
240+
241+
242+
}
243+
244+
245+
var e = new Employee();
246+
console.log(e.age);
247+
248+
Employee.prototype = {
249+
phoneNumber : "4545454",
250+
251+
GetAge : function()
252+
{
253+
return this.name;
254+
}
255+
}
256+
257+
var e = new Employee();
258+
console.log(e.age);
259+
console.log(e.phoneNumber);
260+
console.log(e.GetAge());
261+
```
262+
164263
## Day 10 - ExpressJs
165264

166265
ExpressJs use to build the Node Application, it make faster the devlopment and provide inbuild code for development.<br /><br />

0 commit comments

Comments
 (0)