Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js split array in half

const list = [1, 2, 3, 4, 5, 6]
const half = Math.ceil(list.length / 2);    

const firstHalf = list.splice(0, half)
const secondHalf = list.splice(-half)
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to check variable type jquery 
Javascript :: convert to objectid mongoose 
Javascript :: jquery click add class 
Javascript :: angular validators number only in reactive form 
Javascript :: Node Sass could not find a binding for your current environment: Linux 64-bit with Node.js 10.x 
Javascript :: get the size of the browser jquery 
Javascript :: objectid is not defined node js mongodb 
Javascript :: javascript loop through class elements 
Javascript :: generate random whole numbers within a range javascript 
Javascript :: java sleep 1 sec 
Javascript :: js reload iframe 
Javascript :: open websute react native 
Javascript :: axios send bearer token 
Javascript :: hide header react navigation 
Javascript :: disable all element in div angular 12 
Javascript :: on mouse over in jquery 
Javascript :: react native cover image in parent view 
Javascript :: first letter capital in jquery 
Javascript :: node-fetch post request example 
Javascript :: use json file for data jquery 
Javascript :: invalid host header vue 
Javascript :: jquery trigger change event 
Javascript :: react start new app 
Javascript :: remove extra space in string javascript 
Javascript :: responsive slick slider 
Javascript :: alphabet regex js 
Javascript :: js on load 
Javascript :: get text selected option jquery 
Javascript :: javascript ucwords 
Javascript :: hash change listener js 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =