Загрузка...

TypeScript - Understanding String and its Methods

A string is used to store text data.

let str1: string = "Hello"; // Double quotes
let str2: string = 'Hello'; // Single quotes
let str3: string = `Hello`; // Template string with backtick

No functional difference between using single quotes (') and double quotes (") for strings.

The choice between them typically depends on the following factors:

Handling Embedded Quotes:
Use double quotes if the string contains a single quote: "It's a great day".
Use single quotes if the string contains double quotes: 'She said "Hello"'

Ease of Typing:
Many developers prefer single quotes because they do not require pressing the Shift key on most keyboards.
Methods
-----------
length
toUpperCase()
toLowercase()
includes()
startsWith()
endsWith()
indexOf()
charAt()
slice()
substring()
replace()
trim()
split()
#typescript #typescripttutorial #strings #stringsintypescript
#playwright #playwrightwithtypescript #playwrighttutorial
#automationtesting #automationtestinginterviewquestions
#qatraining #letslearnqa

Видео TypeScript - Understanding String and its Methods канала Lets Learn QA
Яндекс.Метрика
Все заметки Новая заметка Страницу в заметки
Страницу в закладки Мои закладки
На информационно-развлекательном портале SALDA.WS применяются cookie-файлы. Нажимая кнопку Принять, вы подтверждаете свое согласие на их использование.
О CookiesНапомнить позжеПринять