A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://www.w3schools.com/jsref/jsref_codepointat.asp below:

Website Navigation


JavaScript String codePointAt() Method

JavaScript String codePointAt() Examples

Get code point value at the first position in a string:

let text = "HELLO WORLD";
let code = text.codePointAt(0);

Try it Yourself »

Get the code point value at the second position:

let text = "HELLO WORLD";
let code = text.codePointAt(1);

Try it Yourself »

More examples below.

Description

The codePointAt() method returns the Unicode value at an index (position) in a string.

The index of the first position is 0, the second is 1, ....

Difference Between charCodeAt() and codePointAt()

charCodeAt() is UTF-16, codePointAt() is Unicode.

charCodeAt() returns a number between 0 and 65535.

Both methods return an integer representing the UTF-16 code of a character, but only codePointAt() can return the full value of a Unicode value greather 0xFFFF (65535).

For more information about Unicode Character Sets, visit our Unicode Reference.

Syntax

string.codePointAt(index)

Parameters Parameter Description index Optional.
The index (position) in a the string.
Default value = 0. Return Value Type Description Number The code point value at the specified index.
undefined if the index is invalid. More Examples

Get the code point value at the last position:

let text = "HELLO WORLD";
let code = text.charCodeAt(text.length-1);

Try it Yourself »

Get the code point value at the 15th position:

let text = "HELLO WORLD";
let code = text.charCodeAt(15);

Try it Yourself » Browser Support

codePointAt() is an ECMAScript6 (ES6 2015) feature.

JavaScript 2015 is supported in all browsers since June 2017:

Chrome
51 Edge
15 Firefox
54 Safari
10 Opera
38 May 2016 Apr 2017 Jun 2017 Sep 2016 Jun 2016

Track your progress - it's free!


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4