split()
methodIf you want to explode or split a string from a certain character or separator you can use the JavaScript split()
method. The following example will show you how to split a string at each blank space. The returned value will be an array, containing the splitted values.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JavaScript Split a String from Space</title>
</head>
<body>
<script>
var myStr = "The quick brown fox jumps over the lazy dog.";
var strArray = myStr.split(" ");
// Display array values on page
for(var i = 0; i < strArray.length; i++){
document.write("<p>" + strArray[i] + "</p>");
}
</script>
</body>
</html>
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 harsukh21@gmail.com
Laravel 5.5 get current login user details using Auth
Today, we are share with youu how to get...How to Convert a Date to Timestamp in PHP
Use the strtotime() Function You can...How to Check If an Array Includes an Object in JavaScript
Use the JavaScript some() Method You...How to split a string into an array in PHP
Use the PHP explode() function...How to Get the Current URL with JavaScript
Use the window.location.href Property...