Strings

Text values are called strings. Strings are identified with single or double quotation marks.

var firstName = "John";  // we can use double quotation marks
    
    var lastName = 'Doe'; // or single quotation marks
    
    var passportNumber = 'XYZ0123';  
    
    var phoneNumber = "909299999";
    
    var email = '[email protected]';
    
    var bio = "John Doe started his web developer career in 2010 and has contributed to many important projects, like...";

Although the value is composed by numbers only, it won't be used in any calculations so the string type is more indicated(表明的).

here are important operations that can be done with strings

var firstName = "John";

    var lastName = "Doe";

    var fullName = firstName + " " + lastName;

    console.log(fullName); 

    // The result will be "John Doe"

    // Therefore the plus sign (+) is used for concatenation with string values.

hose sequences has a size (length) and each of the characters has their specific position in the sequence, which is the index(索引).

var firstName = "John";

    console.log(firstName.length); // The result will be 4 = 字數

    /* 
    The length property of a string represents its number of characters.
    Each character has its own index, starting from zero.
    White spaces also count. 
    */

    console.log(firstName[0]); // The result will be 'J'=第一個字
    

    // We can access each character of a string using their index inside brackets.
var url = "<https://www.udemy.com>";

    console.log( url.replace( "https://" , "" ) ); // It will show "www.udemy.com"

learn more here.