Skip to content

Commit

Permalink
methods
Browse files Browse the repository at this point in the history
  • Loading branch information
FX committed Aug 10, 2024
1 parent a502c2d commit 78faa10
Show file tree
Hide file tree
Showing 7 changed files with 1,703 additions and 3 deletions.
4 changes: 1 addition & 3 deletions Methods/Built-In-Methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,7 @@ The `Math` object contains various methods for performing mathematical operation
console.log(Math.floor(5.95)) // Output: 5
```

- **`Math.ceil()`**: Rounds a number up to the nearest

integer.
- **`Math.ceil()`**: Rounds a number up to the nearest integer.

```javascript
console.log(Math.ceil(5.05)) // Output: 6
Expand Down
54 changes: 54 additions & 0 deletions Methods/array-methods/usage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
Array(data);

console.log(isArray); // Output: true

````
### 29. **`toLocaleString()`**
The `toLocaleString()` method returns a string representing the elements of the array.
#### **Syntax:**
```javascript
let string = array.toLocaleString(locales, options);
````

#### **Use Cases:**

- **Localized Formatting:** Format arrays for display in a locale-sensitive way, such as converting a number array to a localized string.

#### **Real-World Example:**

```javascript
let numbers = [1, 2, 3.456]
let formatted = numbers.toLocaleString('de-DE')

console.log(formatted) // Output: "1, 2, 3,456"
```

### 30. **`toString()`**

The `toString()` method returns a string representing the specified array and its elements.

#### **Syntax:**

```javascript
let string = array.toString()
```

#### **Use Cases:**

- **Array to String Conversion:** Convert an array into a string for output or concatenation.

#### **Real-World Example:**

```javascript
let colors = ['red', 'green', 'blue']
let colorString = colors.toString()

console.log(colorString) // Output: "red,green,blue"
```

### Conclusion

JavaScript's array methods provide powerful tools for managing and manipulating arrays. Understanding and utilizing these methods effectively can greatly simplify coding tasks and improve the efficiency of your code. From basic operations like adding and removing elements to more advanced transformations and searches, these methods are essential for modern JavaScript development.
Loading

0 comments on commit 78faa10

Please sign in to comment.