References

String.charCodeAt()

Leírás

Visszatér a String példány adott indexéhez (szám) tartozó UTF-16 (Unicode) karakterével.

Szintaxis

charCodeAt(index)

Példa

const x = 'This is string'
 
console.log(x.chartCodeAt(0))
// Expected output: 84
 
console.log(x.chartCodeAt(2))
// Expected output: 105
 
const sentence = 'The quick brown fox jumps over the lazy dog.'
const index = 4
 
console.log(`The character code ${sentence.charCodeAt(index)} is equal to ${sentence.charAt(index)}`)
// Expected output: "The character code 113 is equal to q"
in this article
back to top