Segments

Baseline 2024

Newly available

Since April 2024, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

A Segments object is an iterable collection of the segments of a text string. It is returned by a call to the segment() method of an Intl.Segmenter object.

Try it

Instance methods

Segments.prototype.containing()

Returns an object describing the segment in the original string that includes the code unit at a specified index.

Segments.prototype[Symbol.iterator]()

Returns an iterator to iterate over the segments.

Specifications

Browser compatibility

Desktop Mobile Server
Chrome Edge Firefox Opera Safari Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet WebView Android Deno Node.js
@@iterator 87 87 125 73 14.1 87 125 62 14.5 14.0 87 1.8 16.0.0
Segments 87 87 125 73 14.1 87 125 62 14.5 14.0 87 1.8 16.0.0
containing 87 87 125 73 14.1 87 125 62 14.5 14.0 87 1.8 16.0.0

See also

© 2005–2024 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/segment/Segments