R.zipObj(keys, values) returns a new object: the key at index 0 gets the value at index 0, the key at index 1 gets the value at index 1, and so on. It is the object version of R.zip (official Ramda docs).
Stable since v0.3.0:R.zipObj is not deprecated, experimental, or non-standard. Warning: never feed it untrusted keys — a key named '__proto__' changes the result’s prototype instead of creating a property.
Syntax
Call R.zipObj. Start with this line.
Ramda
R.zipObj(keys, values) or R.zipObj(keys)(values)
Call
What it does
R.zipObj(keys, values) or R.zipObj(keys)(values)
Primary signature.
R.zipObj(...)
Call the list helper.
Prefer import { zipObj } from "ramda" when you want a named import.
Library declarations
Ramda
R.zipObj(keys, values) or R.zipObj(keys)(values)
Parameters
Parameter
Description
keys
Required. Array of property names (non-strings are turned into strings)
values
Optional. Array of values; omit it to get a reusable function
Return Value
Return Value
Description
*
A new plain object with min(keys.length, values.length) assignments
Ramda Examples
Example 1 — Official: Keys Meet Values
The sample from the Ramda docs: three keys, three values, one object.
Each row.['Ana', 31] becomes { name: 'Ana', age: 31 }.
Reuse. The same toRecord works for every table with this header.
Compatibility
Browser & Runtime Support
R.zipObj() is a plain loop inside Ramda 0.3.0+. Without Ramda, Object.fromEntries(keys.map((k, i) => [k, values[i]])) is close, but Object.fromEntries (ES2019) needs Chrome 73+, Firefox 63+, Safari 12.1+, Edge 79+, or Node 12+, and it does not cut to the shorter list.
✓ Ramda 0.3.0+ · Any JS runtime
Ramda.js R.zipObj()
The UMD build (ramda.min.js) is compiled to ES5 syntax, so it runs in Chrome, Firefox, Safari, and Edge, including older versions without Object.fromEntries. Via npm it works in Node.js, Deno, and Bun.
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 ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
BunSupported · JavaScript runtime
Supported
DenoSupported · JavaScript runtime
Supported
Node.jsSupported · Server runtime
Supported
Android WebViewSupported · Modern WebView
Full support
R.zipObj()Universal
Bottom line: Safe in any project with Ramda (check with npm ls ramda). Load ramda.min.js from a CDN in the browser, or npm install ramda for Node, Deno, and Bun. These labs load [email protected].
Frequently Asked Questions
R.zipObj(keys, values) builds a new object where keys[i] becomes a property name and values[i] becomes its value. The official sample R.zipObj(['a', 'b', 'c'], [1, 2, 3]) returns { a: 1, b: 2, c: 3 }.
Only the shorter length is used. Extra keys or extra values are silently dropped, so R.zipObj(['a', 'b', 'c'], [1]) returns { a: 1 }. No error is thrown.
The last value wins, because each key is assigned in order and later assignments overwrite earlier ones. R.zipObj(['a', 'b', 'a'], [1, 2, 3]) returns { a: 3, b: 2 }.
Yes, the Ramda docs say zipObj is equivalent to pipe(zip, fromPairs). zipObj does it in a single pass without building the temporary list of pairs.
Use R.keys(obj) and R.values(obj). Passing them back into R.zipObj rebuilds an equal object. R.toPairs(obj) gives [key, value] pairs instead.
No. R.zipObj has been part of Ramda since v0.3.0 and is stable. It is not deprecated, experimental, or non-standard.