Mauzzz0

Обращение к элементу массива

Aug 11th, 2023
1,501
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const clients = [{id: 1, name: '100'}, {id: 2, name: '200'}];
  2.  
  3. const findFirstClient = (arr: typeof clients) => {
  4.     return arr[0];
  5. }
  6.  
  7. const firstClient = findFirstClient(clients);
  8.  
  9. firstClient.name = 'one';
  10.  
  11. console.log(clients);
  12.  
  13. const firstClientAlternative = clients[0];
  14.  
  15. firstClientAlternative.name = 'two';
  16.  
  17. console.log(clients);
  18.  
Advertisement
Add Comment
Please, Sign In to add comment