Строки (Javascript): различия между версиями

Материал из Информационная безопасностя
Перейти к навигации Перейти к поиску
(Новая страница: «== Строки == * [https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Global_Objects/String Строки (документация)]»)
 
Строка 1: Строка 1:
 
== Строки ==
 
== Строки ==
 
* [https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Global_Objects/String Строки (документация)]
 
* [https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Global_Objects/String Строки (документация)]
 +
 +
<syntaxhighlight lang="javascript" line>
 +
ch = '0'
 +
chCode = ch.charCodeAt()
 +
console.log("Код символа " + ch + " = " + chCode)
 +
 +
console.log("Символ с кодом 55 = " + String.fromCharCode(55))
 +
 +
s = "Hello"
 +
console.log("Длина строки " + s + " = " + s.length)
 +
 +
hasl = s.includes('l')
 +
console.log("Строка " + s + " содержит букву l = " + hasl)
 +
 +
hasz = s.includes('z')
 +
console.log("Строка " + s + " содержит букву z = " + hasz)
 +
 +
indexl = s.indexOf('l')
 +
console.log("В строке " + s + " индекс буквы l = " + indexl)
 +
 +
indexz = s.indexOf('z')
 +
console.log("В строке " + s + " индекс буквы l = " + indexz)
 +
</syntaxhighlight>

Версия 11:09, 25 июня 2021

Строки

 1 ch = '0'
 2 chCode = ch.charCodeAt()
 3 console.log("Код символа " + ch + " = " + chCode)
 4 
 5 console.log("Символ с кодом 55 = " + String.fromCharCode(55))
 6 
 7 s = "Hello"
 8 console.log("Длина строки " + s + " = " + s.length)
 9 
10 hasl = s.includes('l')
11 console.log("Строка " + s + " содержит букву l = " + hasl)
12 
13 hasz = s.includes('z')
14 console.log("Строка " + s + " содержит букву z = " + hasz)
15 
16 indexl = s.indexOf('l')
17 console.log("В строке " + s + " индекс буквы l = " + indexl)
18 
19 indexz = s.indexOf('z')
20 console.log("В строке " + s + " индекс буквы l = " + indexz)