split()
MethodThe JavaScript split()
method is used to split a string using a specific separator string, for example, comma (,
), space, etc. However, if the separator is an empty string (""
), the string will be converted to an array of characters, as demonstrated in the following example:
<script>
// Sample string
var str = "Hello World!";
// Splitting the string
var chars = str.split("");
console.log(chars);
// Prints: ["H", "e", "l", "l", "o", " ", "W", "o", "r", "l", "d", "!"]
// Accessing individual character
alert(chars[0]); // Outputs: H
alert(chars[1]); // Outputs: e
alert(chars[2]); // Outputs: l
alert(chars[chars.length - 1]); // Outputs: !
</script>
Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on [email protected]
Laravel 8 Create Unique Slug Tutorial Example
In this article, we will provide example...How to get current page URL in PHP
Use the PHP $_SERVER Superglob...Laravel 7 - Dynamically Add Input Fields using HandlebarsJs
Hello Artisan In this tutorial i will...Laravel 8 Firebase Phone Number OTP Authentication Example
Firebase is a realtime cloud-hosted NoSQ...How to Get Current URL in Laravel
In blade files or Controllers, you may w...