Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ let objectName = {
key2: value2,
// ...
};

```

### Example:
Expand All @@ -36,7 +35,7 @@ let person = {
firstName: "John",
lastName: "Doe",
age: 30,
isEmployed: true
isEmployed: true,
};

console.log(person);
Expand Down Expand Up @@ -223,13 +222,13 @@ let objectName = Object.create(prototypeObject, {
value: value1,
writable: true,
enumerable: true,
configurable: true
configurable: true,
},
key2: {
value: value2,
writable: true,
enumerable: true,
configurable: true
configurable: true,
},
// ...
});
Expand All @@ -240,16 +239,16 @@ let objectName = Object.create(prototypeObject, {
```javascript title="app.js"
// Create a prototype object
let personPrototype = {
greet: function() {
greet: function () {
return `Hello, my name is ${this.firstName} ${this.lastName}.`;
}
},
};

// Create a new object using the prototype
let person = Object.create(personPrototype, {
firstName: { value: "John" },
lastName: { value: "Doe" },
age: { value: 30 }
age: { value: 30 },
});

console.log(person.greet());
Expand Down Expand Up @@ -277,4 +276,4 @@ In the example above, the `personPrototype` object defines a `greet` method that

## Conclusion

In this tutorial, you learned how to create objects in JavaScript using object literals, constructors, classes, and the `Object.create()` method. Each method has its advantages and use cases, depending on the complexity and structure of the objects you need to create. Understanding these different methods will help you work with objects effectively in JavaScript.
In this tutorial, you learned how to create objects in JavaScript using object literals, constructors, classes, and the `Object.create()` method. Each method has its advantages and use cases, depending on the complexity and structure of the objects you need to create. Understanding these different methods will help you work with objects effectively in JavaScript.
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@ let person = {
firstName: "John",
lastName: "Doe",
age: 30,
isEmployed: true
isEmployed: true,
};

console.log(person);
```

In this example, `person` is an object with four properties:
In this example, `person` is an object with four properties:

- `firstName` is a property with the value `"John"`.
- `lastName` is a property with the value `"Doe"`.
- `age` is a property with the value `30`.
Expand Down Expand Up @@ -72,7 +73,7 @@ Consider an online shopping cart. You might represent a shopping cart as an obje
let shoppingCart = {
apple: 2,
banana: 3,
orange: 1
orange: 1,
};

console.log(shoppingCart);
Expand All @@ -84,4 +85,4 @@ Objects are versatile and can be used to model a wide range of real-world entiti

## Conclusion

In this tutorial, you learned about objects in JavaScript, how to create objects, and the importance of objects in JavaScript programming. Objects are a fundamental part of JavaScript and are used to represent complex data structures in a flexible and dynamic way.
In this tutorial, you learned about objects in JavaScript, how to create objects, and the importance of objects in JavaScript programming. Objects are a fundamental part of JavaScript and are used to represent complex data structures in a flexible and dynamic way.
2 changes: 1 addition & 1 deletion docs/javascript/data-types/primitive-types/bigint.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,4 @@ The `BigInt` data type was introduced in ECMAScript 2020 (ES11) to provide a way

## Conclusion

The `BigInt` data type in JavaScript provides a way to work with integers of arbitrary length, overcoming the limitations of the `Number` data type for very large numbers. By using `BigInt` values, you can perform precise integer arithmetic and handle calculations that exceed the maximum safe integer value in JavaScript.
The `BigInt` data type in JavaScript provides a way to work with integers of arbitrary length, overcoming the limitations of the `Number` data type for very large numbers. By using `BigInt` values, you can perform precise integer arithmetic and handle calculations that exceed the maximum safe integer value in JavaScript.
6 changes: 3 additions & 3 deletions docs/javascript/data-types/primitive-types/boolean.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ console.log(a <= b); // Output: false
You can use the conditional (ternary) operator to assign values based on a condition. The syntax of the conditional operator is as follows:

```javascript
condition ? valueIfTrue : valueIfFalse
condition ? valueIfTrue : valueIfFalse;
```

Here's an example of using the conditional operator with `Boolean` values:
Expand Down Expand Up @@ -143,7 +143,7 @@ console.log(Boolean(null)); // Output: false
console.log(Boolean(undefined)); // Output: false
console.log(Boolean({})); // Output: true
console.log(Boolean([])); // Output: true
console.log(Boolean(function() {})); // Output: true
console.log(Boolean(function () {})); // Output: true
console.log(Boolean(true)); // Output: true
console.log(Boolean(false)); // Output: false
```
Expand All @@ -156,4 +156,4 @@ The `Boolean()` function is useful when you need to convert values to `Boolean`

## Conclusion

In this tutorial, you learned about the `Boolean` data type in JavaScript, how to create `Boolean` values using `true` and `false` literals, and common operations with `Boolean` values. You also learned how to convert values to `Boolean` using the `Boolean()` function.
In this tutorial, you learned about the `Boolean` data type in JavaScript, how to create `Boolean` values using `true` and `false` literals, and common operations with `Boolean` values. You also learned how to convert values to `Boolean` using the `Boolean()` function.
4 changes: 2 additions & 2 deletions docs/javascript/data-types/primitive-types/null.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ In the example above, the strict equality comparison (`===`) checks if `nullValu
You can use the conditional (ternary) operator to assign values based on a condition. The syntax of the conditional operator is as follows:

```javascript
condition ? valueIfTrue : valueIfFalse
condition ? valueIfTrue : valueIfFalse;
```

Here's an example of using the conditional operator with `null` values:
Expand All @@ -147,4 +147,4 @@ The conditional operator evaluates the condition (`nullValue` in this case) and

## Conclusion

In this tutorial, you learned about the `null` data type in JavaScript, how to create `null` values, and common operations with `null` values. You can use the `null` value to represent the intentional absence of any object value in your JavaScript programs.
In this tutorial, you learned about the `null` data type in JavaScript, how to create `null` values, and common operations with `null` values. You can use the `null` value to represent the intentional absence of any object value in your JavaScript programs.
8 changes: 4 additions & 4 deletions docs/javascript/data-types/primitive-types/symbol.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ let firstName = Symbol("firstName");
let person = {
[firstName]: "John",
lastName: "Doe",
age: 30
age: 30,
};

console.log(person[firstName]); // Output: John
Expand All @@ -79,9 +79,9 @@ let logSymbol = Symbol("log");

// Create an object with a symbol property
let logger = {
[logSymbol]: function(message) {
[logSymbol]: function (message) {
console.log(message);
}
},
};

logger[logSymbol]("Logging a message"); // Output: Logging a message
Expand Down Expand Up @@ -131,4 +131,4 @@ Symbols are a powerful feature in JavaScript that allow you to create unique ide

## Conclusion

In JavaScript, the `Symbol` data type is used to create unique and immutable values that can be used as property keys in objects. Symbols are guaranteed to be different from other values and are often used to create private properties, avoid property name collisions, and define special behaviors in objects. By using symbols, you can create unique identifiers that are not accessible using regular property access methods, making them a powerful tool for defining object properties and behaviors.
In JavaScript, the `Symbol` data type is used to create unique and immutable values that can be used as property keys in objects. Symbols are guaranteed to be different from other values and are often used to create private properties, avoid property name collisions, and define special behaviors in objects. By using symbols, you can create unique identifiers that are not accessible using regular property access methods, making them a powerful tool for defining object properties and behaviors.
Loading