Learn JavaScript
Lesson 1 - Introduction To JavaScript
Lesson 2 - Basic JavaScript Syntax
Lesson 3 - Control Flow
Lesson 4 - Functions
Lesson 5 - Basic Data Structures
Lesson 7 - Basic Array Operations
Lesson 8 - Exception Handling
Lesson 9 - Packages
Lesson 10 - User Input
JavaScript's split()
function enables you to split a string using a specific separator.
const myStr = "A, B, C, D"; const myArr = myStr.split(", "); console.log(myArr); console.log(myArr[0]);
Here, we split the myStr
using the separator ,
.
Note that the split()
function generates an array after splitting a string.