1. First use js to define a variable, which is a string variable, as shown in the figure. The strings are separated by commas.
2. To convert a string into data, we can use the built-in method of JS, the split method will do. The important thing to pay attention to with this method is the parameters. Since the string is separated by commas, Just enter commas for parameters.
3. In order to verify the effect, you can output the results to the console. Use the console.log method to output the results.
In 4. In the script, directly call the method just now, and it will be executed directly when the page is opened.
5. Open the browser’s developer tools and click ‘Console’.
6. You can see the output result here. You can see that the result is an array.
7. Click to expand the array and you can see the contents of each item in the array.