To split a string with multiple characters, you should pass a regular expression as an argument to the
You can use
 to define a set of characters, as opposed to a single character, to match.
const sentence = 'Hey, check out this example.'; const example = sentence.split(/[s,]+/); example; // ["Hey", "check", "out", "this", "example."] const sample = 'this-is:a_test'; sample.split(/[-:_]/); // [ 'this', 'is', 'a', 'test' ]
- Variables: Variables are used to store data. They are declared using the
- Operators: Operators are used to perform operations on data.
- Control flow statements: Control flow statements allow you to control the order in which your code is executed.
- Functions: Functions are blocks of code that can be reused.
- Objects: Objects are used to store data in key-value pairs.
- Arrays: Arrays are used to store data in a sequential order.
- Events and event handlers: Events are notifications that are sent by the browser when something happens, such as when the user clicks on an element or moves the mouse over an element. Event handlers are functions that are called in response to an event.