Skip to content

Commit 8dbd346

Browse files
committed
config objects
1 parent f45b501 commit 8dbd346

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

js_basics/objects.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//object -> there are ywo ways to declare an object
2+
// 1 using constructor == singleton become
3+
// 2 using literal == singleton not become
4+
5+
//lets create an object in liternal way
6+
const user = {
7+
name : "Krish",
8+
age : 24
9+
};
10+
11+
// user.age = 552; //for update object value
12+
13+
// Object.freeze(user); //if want to no one can change your value of object then freeze
14+
// user.age = 852;
15+
// console.log(user);
16+
17+
18+
19+
//in object we define out key and value in pair
20+
21+
//to access the object
22+
// console.log(user.name);
23+
// console.log(user["age"]);
24+
25+
// What are symbols JavaScript?
26+
// Symbols are used to create object properties, for example, when you want to assign a unique identifier to an object. They can also be used as a way to create private properties in objects, as they are not enumerable. In addition, Symbols can be used to create unique constants, which are useful when creating APIs.
27+
28+
//object with function
29+
// user.greetings = function(){
30+
// console.log("Hello js user");
31+
// }
32+
// user.greetingsTwo = function(){
33+
// console.log(`Hello js user + ${this.age}`);
34+
// }
35+
36+
// console.log(user.greetings());
37+
// console.log(user.greetingsTwo());

0 commit comments

Comments
 (0)