JavaScript String codePointAt () yöntemi, Unicode nokta değerini belirten bir tamsayı döndürür.
codePointAt()
Yöntemin sözdizimi şöyledir:
str.codePointAt(pos)
Burada str bir dizedir.
codePointAt () Parametreleri
codePointAt()
Yöntem alır:
- pos -
str
Kod noktası değerini döndürmek için bir öğenin konumu .
CodePointAt () 'dan dönüş değeri
- Verilen konumdaki karakterin kod noktası değerini temsil eden bir sayı döndürür.
- Konumda
undefined
hiçbir öğe bulunmazsa döner.
Örnek: codePointAt () yöntemini kullanma
let sentence = "Happy Birthday"; let codePt1 = sentence.codePointAt(1); // 97 console.log(`Unicode Code Point of '$(sentence.charAt(1))': $(codePt1)`); for (let codePoint of sentence.slice(0,5))( console.log(codePoint, codePoint.codePointAt(0)); ) let codePt3 = sentence.codePointAt(100); console.log(codePt3); // undefined
Çıktı
Unicode Kod 'a' Noktası: 97 H 72 a 97 p 112 p 112 y 121 tanımsız
Önerilen Okuma: JavaScript String fromCodePoint ()