Home >Web Front-end >JS Tutorial >A brief discussion on JavaScript strings and arrays_javascript skills
JavaScript String
A string is a collection of characters, including English letters, punctuation marks, special symbols, Chinese characters, etc.
In JavaScript, strings can be represented using double quotes (" ") or single quotes (' ').
Double quotes and single quotes must appear in pairs. Double quotes can contain single quotes, and single quotes can also contain double quotes.
For example:
The length of the string is obtained by length, for example:
JavaScript Array
Arrays are used to store a series of values in separate variables.
In JavaScript, arrays can be defined in the following ways.
Use keyword new to create array objects
For example, create an array named myArray and assign a value:
You can also assign values while creating the object:
Use [ ] to create an array directly
For example, create an array named myArray and assign a value:
Of course, you can also assign values while creating the array:
Create an array of key/value pairs
For example, create an array named myArray and assign a value:
Modify array
Arrays can be modified after creation and assignment, for example:
Array length
In JavaScript, use length to get the array length, for example:
The above is the entire content of this article, I hope you all like it.