A check that returns true when a string ends with a substring, or a list ends with a sublist. Items are compared with R.equals, so objects match by value. Part of Ramda List since v0.24.0 (stable — not deprecated, experimental, or non-standard).
Why not the native method?"app.js".endsWith(".js") only works on strings and must be called on the data. R.endsWith(".js") is curried and data-last, so it drops straight into R.filter — and it works on arrays too.
Syntax
Call R.endsWith. Start with this line.
Ramda
R.endsWith(suffix, list)
Call
What it does
R.endsWith(suffix, list)
Primary signature.
R.endsWith(...)
Call the list helper.
Prefer import { endsWith } from "ramda" when you want a named import.
Library declarations
Ramda
R.endsWith(suffix, list)
Parameters
Parameter
Description
suffix
Required. The ending to look for (string or array)
Case-sensitive.".PNG" is not ".png", so the first check is false.
Normalize first.R.toLower turns "PHOTO.PNG" into "photo.png".
Any of several.R.anyPass returns true if eitherendsWith test passes → true.
No match."notes.txt" fails both tests → false.
Compatibility
Browser & Runtime Support
R.endsWith is a Ramda List helper since v0.24.0. It is built from R.takeLast and R.equals, not the native String.prototype.endsWith, so it runs anywhere Ramda runs — browsers via CDN or bundler, and Node.js / Bun / Deno with npm install ramda.
✓ Stable · Ramda 0.24.0+
R.endsWith()
Support depends on the Ramda version you load, not on a browser feature. Load Ramda 0.24.0 or later; older versions do not have endsWith.
100%Modern browsers & runtimes
Google ChromeModern versions · Desktop & Mobile
Full support
Mozilla FirefoxModern versions · Desktop & Mobile
Full support
Apple SafariModern versions · macOS & iOS
Full support
Microsoft EdgeChromium-based
Full support
OperaModern versions
Full support
Samsung InternetModern versions · Android
Full support
Android WebViewModern WebView
Full support
Internet ExplorerNot a target for current Ramda releases
Legacy
Node.jsMaintained LTS · npm install ramda
Supported
Bunimport from "ramda"
Supported
Denoimport from "npm:ramda"
Supported
R.endsWithRamda 0.24.0+
Bottom line: Safe for production in any modern browser or JavaScript runtime once Ramda 0.24.0+ is loaded. The labs on this page use [email protected] from a CDN.
Frequently Asked Questions
R.endsWith(suffix, list) returns true when a string ends with the given substring, or when a list ends with the given sublist. Docs samples: R.endsWith('c', 'abc') //=> true and R.endsWith(['c'], ['a', 'b', 'c']) //=> true.
Ramda puts the data last so you can curry: R.endsWith('.png') is a ready-made test you can pass to R.filter. This is the opposite order of the native 'abc'.endsWith('c') method call.
No — that returns false. For lists the suffix must also be a list: R.endsWith([3], [1, 2, 3]) //=> true. A string suffix against an array (or the reverse) is also false.
It uses R.equals, a deep, value-based comparison. So R.endsWith([{ id: 2 }], [{ id: 1 }, { id: 2 }]) is true even though the two { id: 2 } objects are different references.
An empty suffix ('' or []) always returns true. A suffix longer than the list always returns false. The check is also case-sensitive.
No. R.endsWith has been part of Ramda since v0.24.0 and is stable — not deprecated, experimental, or non-standard.