R.startsWith(prefix, list) returns true when a string or list begins with a given prefix, and false otherwise (official Ramda docs). Lists are compared item by item by value, and R.startsWith(prefix) is a reusable test for R.filter and friends.
Stable since v0.24.0:R.startsWith is not deprecated, experimental, or non-standard. For strings only, JavaScript has the native String.prototype.startsWith(); arrays have no built-in equivalent.
Syntax
Call R.startsWith. Start with this line.
Ramda
R.startsWith(prefix, list) or R.startsWith(prefix)(list)
Call
What it does
R.startsWith(prefix, list) or R.startsWith(prefix)(list)
Primary signature.
R.startsWith(...)
Call the list helper.
Prefer import { startsWith } from "ramda" when you want a named import.
Library declarations
Ramda
R.startsWith(prefix, list) or R.startsWith(prefix)(list)
Parameters
Parameter
Description
prefix
Required. String or Array. What the value should begin with
list
Optional. String or Array. The value to check; omit it to get a reusable test
Return Value
Return Value
Description
*
true or false
Ramda Examples
Example 1 — Strings and Lists (Official Samples)
The same function checks a string prefix and a list prefix.
Case matters.'H' and 'h' are different, so the plain check is false.
Lowercase first.R.toLower turns 'HI!' into 'hi!' before the test runs.
Combine.R.pipe joins both steps into one reusable test.
Only the start.'ship' contains 'hi' but does not start with it, so it is dropped.
Compatibility
Browser & Runtime Support
R.startsWith() is plain JavaScript inside Ramda 0.24.0+. It is built on R.take and R.equals, not on the ES2015 String.prototype.startsWith, so support depends only on loading Ramda.
✓ Ramda 0.24.0+ · Any JS runtime
Ramda.js R.startsWith()
The UMD build (ramda.min.js) uses ES5 syntax, so it runs in every modern browser. Via npm it works in Node.js, Deno, and Bun with require or import.
100%With Ramda loaded
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerEnd of life · ES5 build may load, untested
Legacy only
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
Node.jsSupported · npm install ramda
Supported
DenoSupported · npm:ramda
Supported
BunSupported · bun add ramda
Supported
R.startsWith()Universal
Bottom line: Safe in any project that loads Ramda 0.24.0 or later. Use ramda.min.js from a CDN in the browser, or npm install ramda for Node, Deno, and Bun. The Try-it labs load [email protected] and use modern syntax (const).
Frequently Asked Questions
A boolean. R.startsWith(prefix, list) is true when the string or list begins with prefix. R.startsWith('a', 'abc') is true and R.startsWith(['b'], ['a', 'b', 'c']) is false.
The native method works only on strings and is called on the text: 'abc'.startsWith('a'). R.startsWith takes the prefix first, is curried, and also works on arrays, comparing items by value with R.equals. The native method has an optional position argument; Ramda does not.
Yes. R.startsWith('hi', 'Hi there') is false. Lowercase the text first, for example R.pipe(R.toLower, R.startsWith('hi')).
An empty prefix ('' or []) always returns true, even for an empty list. A prefix longer than the list always returns false.
Yes. Items are compared by value, so R.startsWith([{ type: 'login' }], steps) is true when the first step looks like { type: 'login' }, even though it is a different object.
No. R.startsWith has been a stable Ramda List function since v0.24.0. It is not deprecated, experimental, or non-standard.