Standard built-ins

Segments.prototype.containing()

Try the free JavaScript compiler

Return the segment record covering a UTF-16 index, or undefined outside the string. The Segments object is produced by Intl.Segmenter.segment.

Formal Syntax & Structure

javascript syntaxjavascript
segments.containing(index)

Parameters & Attributes

NameTypeDescription
indexNumberUTF-16 position.

Return Value

Object | undefined

Containing segment record.

Working Example

Example Snippetjavascript
const s=new Intl.Segmenter("en").segment("éx");console.log(s.containing(1).index);
JavaScript Reference