Skip to content

Instantly share code, notes, and snippets.

@lelouchB
Last active November 1, 2019 06:55
Show Gist options
  • Save lelouchB/0e1d27671c24831fdb26ef4ec0394381 to your computer and use it in GitHub Desktop.
Save lelouchB/0e1d27671c24831fdb26ef4ec0394381 to your computer and use it in GitHub Desktop.
const string1 = `1,2,3,My,Name,is,Ney`
const array1 = string1.split(',')
const arrayWithLimit = string1.split(',', 4)
const arrayWithoutSeperator = string1.split()
console.log(array1, arrayWithLimit, arrayWithoutSeperator)
//[ '1', '2', '3', 'My', 'Name', 'is', 'Ney' ] [ '1', '2', '3', 'My' ] [ '1,2,3,My,Name,is,Ney' ]
const string2 = `123MyNameisNey`
const array2 = string2.split('')
console.log(array2)
//["1", "2", "3", "M", "y", "N", "a", "m", "e", "i", "s", "N", "e", "y"]
const string3 = `1,2,3,My,Name,is,Ney`
const array3 = string3.split(',')
console.log(array3) //[ '1', '2', '3', 'My', 'Name', 'is', 'Ney' ]
const string4 = `1and2and3andMyandNameandisandNey`
const array4 = string4.split('and')
console.log(array4) //[ '1', '2', '3', 'My', 'Name', 'is', 'Ney' ]
const string5 = `1-2-3-My-Name-is-Ney`
const array5 = string5.split('-')
console.log(array5) //[ '1', '2', '3', 'My', 'Name', 'is', 'Ney' ]
const string6 = `1=2=3=My=Name=is=Ney`
const array6 = string.split('=')
console.log(array6) //[ '1', '2', '3', 'My', 'Name', 'is', 'Ney' ]
const string7 = `1:2:3:My:Name:is:Ney`
const array7 = string7.split(':')
console.log(array7) //[ '1', '2', '3', 'My', 'Name', 'is', 'Ney' ]
const string8 = `1 2 3 My Name is Ney`
const array8 = string8.split(' ')
console.log(array8) //[ '1', '2', '3', 'My', 'Name', 'is', 'Ney' ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment