// double quotes var name = "John Doe"; //single quotes var gender = "male"; console.log("Name: ", name); console.log("Gender: ", gender);
Name: John Doe
You can also use quotes inside strings.
Strings as Objects:
If you create a string using literal then the type will be a string. But, if you create string defined as object then the type will object.
Creating strings using objects is not a good practice. It affects the execution of code. Code execution will be slow. So, create strings using literals.
Long Code Line breaking:
- You can break the long code line by breaking text string using a single backslash. But using this method for long code lines is not good practice. It is not supported by some browsers.
- You can break the long code line by breaking a string using string addition.
- If you want to break the single long code line into multiple lines. You can break it after the operator.
- Using template literals you can break the long string.
You can refer code below for above long code lines breaking methods.