Standard built-ins
Segments.prototype.containing()
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
| Name | Type | Description |
|---|---|---|
| index | Number | UTF-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);