Skip to content

Commit cd3818e

Browse files
authored
Update 29-Object.md
1 parent 2cee77d commit cd3818e

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

notes/English/29-Object.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
### What is an object in javascript
1+
### What is an object ?
22
In JavaScript, an object is a collection of key-value pairs, where the keys are strings (or symbols) and the values can be any JavaScript data type, including other objects. Objects in JavaScript are dynamic, meaning that their properties can be added, modified, or removed at runtime. They are also reference types, which means that when you assign an object to a variable, the variable holds a reference to the object in memory rather than a copy of its value.
33

44

5-
### What is Object literal syntax in javascript
5+
### What is Object literal syntax ?
66
Object literal syntax in JavaScript is a way to create an object by directly defining its properties and values within curly braces. It is a shorthand notation for creating objects without using the constructor function. For example:
77

8-
```
8+
```javascript
99
const myObject = {
1010
name: 'John',
1111
age: 30,
@@ -16,7 +16,7 @@ const myObject = {
1616
This creates an object `myObject` with three properties: `name`, `age`, and `city`, each with a corresponding value. Object literal syntax is a common and convenient way to create objects in JavaScript.
1717

1818

19-
### How to create Object using new keyword in javascript
19+
### How to create Object using new keyword ?
2020
To create an object using the `new` keyword in JavaScript, you can define a constructor function and use the `new` keyword to instantiate an object of that type. Here's an example:
2121

2222
```
@@ -36,7 +36,7 @@ In this example, we define a constructor function called `Person`, which takes t
3636
When the `new` keyword is used with a constructor function, it creates a new object, sets the `this` keyword to refer to that object, executes the code inside the constructor function (which typically sets up the object's properties), and then returns the new object.
3737

3838

39-
### Explain Object Annotations in javascript
39+
### Explain Object Annotations
4040
Object Annotations in javascript are a way to define and initialize objects. An object is created by enclosing key-value pairs within curly braces `{}`. The keys represent the properties of the object and the values represent the values of those properties.
4141

4242
There are two ways to add properties to an object using object annotations:
@@ -69,7 +69,7 @@ const myObject = {
6969
In this case, the properties are defined inside the curly braces `{}` separated by commas `,`.
7070

7171

72-
### Explain Dot annotation in javascript
72+
### Explain Dot annotation
7373
In JavaScript, dot notation is a way to access properties and methods of an object using the dot (.) operator. Using dot notation, you can access properties and methods of an object by specifying the object name followed by a dot and then the property or method name.
7474

7575
For example, if you have an object called "person" with properties "name" and "age", you can access the name property using dot notation like this:
@@ -100,15 +100,15 @@ person.sayHello(); // Output: "Hello!"
100100
Note that dot notation only works for accessing properties and methods that have valid identifier names. For properties or methods with special characters or reserved words in their names, you must use bracket notation instead.
101101

102102

103-
### Explain Bracket annotation in javascript
103+
### Explain Bracket annotation
104104
Bracket annotation in JavaScript is a way of accessing an object's property using square brackets and a string key instead of the traditional dot notation. For example, instead of writing `object.property`, you can write `object['property']`. This is useful when the property name is dynamic or contains special characters that are not valid as identifier names.
105105

106106
For instance, if you have an object `myObj` with a property whose name is stored in a variable `propName`, you can access it using bracket annotation like this: `myObj[propName]`. Similarly, if the property name contains special characters like spaces or hyphens, you can use bracket annotation to access it: `myObj['special-prop']`.
107107

108108
Note that while most objects in JavaScript support bracket annotation, there are some exceptions, such as primitive values (e.g., strings, numbers) and some built-in objects like `Math` or `Date`.
109109

110110

111-
### Explain Object properties : Key and Value in javascript
111+
### Explain Object properties : Key and Value
112112
In JavaScript, an object is a collection of key-value pairs. The "key" in an object refers to the unique identifier that is used to access its corresponding "value".
113113

114114
For example, consider an object representing a person:
@@ -131,7 +131,7 @@ console.log(person["age"]); // Output: 30
131131
```
132132

133133

134-
### Explain Array inside an Object in javascript
134+
### Explain Array inside an Object
135135
In JavaScript, an array inside an object is a way to store multiple values in a single property of an object. This property can be accessed using the dot notation or square bracket notation.
136136

137137
For example, let's say we have an object called "car" with properties such as "make", "model", and "year". We can add an array called "features" that includes additional information about the car, such as its color, engine size, and transmission type.
@@ -157,7 +157,7 @@ console.log(car["features"][1]); // Output: "2.5L"
157157
So, by using an array inside an object, we can organize related data together and easily access it when needed.
158158

159159

160-
### Explain Function inside an Object in javascript
160+
### Explain Function inside an Object
161161
In JavaScript, objects can contain functions as properties, which are called "methods". These methods can be accessed and invoked using dot notation.
162162

163163
For example, consider an object representing a car:
@@ -204,7 +204,7 @@ let car = {
204204
Here, `this.make` and `this.model` refer to the `make` and `model` properties of the `car` object.
205205

206206

207-
### Explain Uses of this inside an Object in javascript
207+
### Explain Uses of this inside an Object
208208
In JavaScript, `this` refers to the current object that a method is being called on, or the object that a function is invoked with. It allows you to access and modify properties and methods of the object within which `this` is used.
209209

210210
Some common uses of `this` inside an object include:
@@ -220,7 +220,7 @@ Some common uses of `this` inside an object include:
220220
Note that the value of `this` depends on how a function is called. When a function is called without an explicit context (i.e., as a standalone function), `this` refers to the global object (e.g., `window` in the browser). To avoid this, you can use the `bind`, `call`, or `apply` methods to explicitly set the value of `this`.
221221

222222

223-
### Explain Object functions Keys(), Values(), entries() in javascript
223+
### Explain Object functions : Keys(), Values(), entries()
224224
In JavaScript, object functions `keys()`, `values()`, and `entries()` are used to extract information from an object.
225225

226226
- The `keys()` function returns an array of all the keys within an object.

0 commit comments

Comments
 (0)