Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

duplicate an array in javascript n times

const makeRepeated = (arr, repeats) =>
  Array.from({ length: repeats }, () => arr).flat();
  
console.log(makeRepeated([1, 2, 3], 2));
Comment

duplicate numbers in an array javascript

[1, 1, 2, 2, 3].filter((element, index, array) => array.indexOf(element) !== index) // [1, 2]
Comment

PREVIOUS NEXT
Code Example
Javascript :: You need to authorize this machine using `npm adduser` 
Javascript :: newtonsoft.json string to object 
Javascript :: javascript traverse 
Javascript :: js unique array 
Javascript :: vue fetch api 
Javascript :: how to check if array is empty or not in javascript 
Javascript :: connecting react to socket.io 
Javascript :: how to get current date in react js 
Javascript :: if select option disabled jquerz 
Javascript :: remove a specific element from an array 
Javascript :: copyright js 
Javascript :: jquery selector checked 
Javascript :: how to check if a string is in a string js 
Javascript :: wait for element to load 
Javascript :: word count javascript 
Javascript :: how to change a string to number in javascript 
Javascript :: jquery get all checkbox checked 
Javascript :: livewire file upload progress 
Javascript :: ajax jquery errors 
Javascript :: jquery get mouse page left and top 
Javascript :: javascript replace all occurrences of string 
Javascript :: draw line in javascript 
Javascript :: javascript newline in alert box 
Javascript :: remove single item from array in angular 
Javascript :: check date format javascript 
Javascript :: fluttter http get 
Javascript :: vue on click router push not working 
Javascript :: how do i listen to a keypress in javascript 
Javascript :: js find space in string 
Javascript :: js how to get data fetch 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =