How to push multiple values to an array in TypeScript

2 Answers

0 votes
const arr = ['c', 'typescript', 'c++'];
 
arr.push('c#', 'php', 'go');
 
console.log(arr);
   
   
   
   
/*
run:
   
["c", "typescript", "c++", "c#", "php", "go"] 
   
*/

 



answered Jun 27, 2022 by avibootz
0 votes
let arr = ['c', 'typescript', 'c++'];
 
arr = [...arr, 'c#', 'php', 'go']; 
 
console.log(arr);
   
   
   
   
/*
run:
   
["c", "typescript", "c++", "c#", "php", "go"] 
   
*/

 



answered Jun 27, 2022 by avibootz

Related questions

1 answer 138 views
2 answers 144 views
2 answers 150 views
1 answer 163 views
4 answers 133 views
...