let string = '30 Days Of JavaScript' console.log(string.split()) // Changes to an array -> ["30 Days Of JavaScript"] console.log(string.split(' ')) // Split to an array at space -> ["30", "Days", "Of", "JavaScript"] let firstName = 'Asabeneh' console.log(firstName.split()) // Change to an array - > ["Asabeneh"] console.log(firstName.split('')) // Split to an array at each letter -> ["A", "s", "a", "b", "e", "n", "e", "h"] let countries = 'Finland, Sweden, Norway, Denmark, and Iceland' console.log(countries.split(',')) // split to any array at comma -> ["Finland", " Sweden", " Norway", " Denmark", " and Iceland"] console.log(countries.split(', ')) // ["Finland", "Sweden", "Norway", "Denmark", "and Iceland"]
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter