![]() |
The spread operator in Typescript, denoted by three dots (`…`), is a powerful tool, that allows you to spread the elements of an array or objects into another array or objects. This operator makes it easy to copy arrays, combine arrays, or create shallow copies of iterable. Syntax...operatingValue
Example 1: The below code implements the spread operator to create a shallow copy of an array. Javascript
Output: [1, 2, 3]
Example 2: The below code combines the elements of two different arrays into a single array using spread operator. Javascript
Output: [1, 2, 3, 4]
Example 3: The below code implements the spread operator to create a shallow copy of an object. Javascript
Output: { Example: The below code modifies the value of an property of an object using spread operator. Javascript
Output: { |
Reffered: https://www.geeksforgeeks.org
Geeks Premier League |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 13 |