What do you want to save?
Add Code snippet
New code examples
-
TypeScript 2022-03-27 17:05:06
use of slice and splice add elements array
function frankenSplice(arr1, arr2, n) { // Create a copy of arr2. let combinedArrays = arr2.slice() // [4, 5, 6] // Insert all the elements of arr1 into arr2 beginning // at the index specified by n. We're using the spread /... Add solution -
Javascript 2022-03-27 07:05:02
queue data structure in javascript 2018
var Queue = (()=>{ const map = new WeakMap(); let _items = [] class Queue{ constructor(...items){ //initialize the items in queue map.set(this, []); _items = map.get(this); // enqueuing the items passed to the construc... Add solution -
Javascript 2022-03-16 23:45:12
permutaciones con repeticion javascript
function permutator (input) { var set =[]; function permute (arr, data) { var cur, memo = data || []; for (var i = 0; i < arr.length; i++) { cur = arr.splice(i, 1)[0]; if (arr.length === 0) set.push(memo.concat([cur])); ... Add solution -
TypeScript 2022-03-16 23:35:15
transform snake case in camel case typescript
const toCamelCase = (str: string): string =>{ let charsLowerCase = str.toLowerCase().split(''); let camelCaseKey = ''; for (let pos = 0; pos < charsLowerCase.length; pos++) { if (charsLowerCase[pos] === '_') { ... Add solution -
Other 2022-03-16 12:00:07
javascript arrays
//Creating a list var fruits = ["Apple", "Banana", "Cherry"]; //Creating an empty list var books = []; //Getting element of list //Lists are ordered using indexes //The first element in an list has an index of 0, //the sec... Add solution -
Javascript 2022-03-11 08:10:23
javascript splice
let arr = ['foo', 'bar', 10, 'qux']; // arr.splice(<index>, <steps>, [elements ...]); arr.splice(1, 1); // Removes 1 item at index 1 // => ['foo', 10, 'qux'] arr.splice(2, 1, 'tmp'); // Replaces 1 item at index 2 with 'tmp' // => ['... Add solution -
Javascript 2022-03-07 04:05:16
remove a specific item from an array javascript
var colors = ["red","blue","car","green"]; var carIndex = colors.indexOf("car");//get "car" index //remove car from the colors array colors.splice(carIndex, 1); // colors = ["red",&... Add solution