---
title: "Object helpers"
description: "Tiny, dependency-free object and enum helpers — `pick`, `omit`, `getEnumValue`, and the `isArrayOfArray` type guard."
canonical_url: "https://bitrix24.github.io/b24jssdk/docs/working-with-the-rest-api/tools-object-helpers"
last_updated: "2026-07-03"
---
# Object helpers

> Tiny, dependency-free object and enum helpers — `pick`, `omit`, `getEnumValue`, and the `isArrayOfArray` type guard.

## Overview

A handful of small, dependency-free helpers used across the SDK for reshaping objects and narrowing types. All four are plain functions exported from `@bitrix24/b24jssdk`:

- **`pick`** — a new object containing only the listed keys.
- **`omit`** — a shallow copy with the listed keys removed.
- **`getEnumValue`** — resolve a raw string/number to the matching enum member (or `undefined`).
- **`isArrayOfArray`** — a type guard distinguishing an array of arrays from a flat array.

```ts
import { pick, omit } from '@bitrix24/b24jssdk'

const user = { ID: '1', NAME: 'Ann', EMAIL: 'ann@example.com' }

pick(user, ['ID', 'NAME']) // { ID: '1', NAME: 'Ann' }
omit(user, ['EMAIL'])      // { ID: '1', NAME: 'Ann' }
```

## Method Signature

```ts-type
pick<Data extends object, Keys extends keyof Data>(
  data: Data,
  keys: Keys[]
): Pick<Data, Keys>

omit<Data extends object, Keys extends keyof Data>(
  data: Data,
  keys: Keys[]
): Omit<Data, Keys>

getEnumValue<T extends Record<string, string | number>>(
  enumObj: T,
  value: string | number
): T[keyof T] | undefined

isArrayOfArray<A>(item: A[] | A[][]): item is A[][]
```

## Key Concepts

- **`pick` / `omit` are shallow.** `pick` copies the chosen property references into a fresh object; `omit` spreads `data` into a shallow clone and `delete`s the listed keys. Nested objects are shared by reference, and the original `data` is never mutated. Both return a precisely-typed result (`Pick<Data, Keys>` / `Omit<Data, Keys>`).
- **`getEnumValue` is a runtime lookup.** It checks whether `value` is present in `Object.values(enumObj)` and, if so, returns it narrowed to the enum's member type; otherwise it returns `undefined`. It works with both string and numeric enums and is the safe way to turn an untrusted REST string into a typed enum member.
- **`isArrayOfArray` only inspects the first element.** It returns `Array.isArray(item[0])` — it does not scan the whole array. On an empty array `item[0]` is `undefined`, so it returns `false`. The SDK uses it to tell a single list of batch calls apart from a list-of-lists.

## Error Handling

None of these helpers throw. `pick` / `omit` operate on a copy and leave the input untouched, `getEnumValue` returns `undefined` for a value that is not a member of the enum, and `isArrayOfArray` returns `false` for an empty array rather than failing.

## Examples

Reshape a REST record before sending it on:

```ts
import { pick, omit } from '@bitrix24/b24jssdk'

const contact = { ID: '42', NAME: 'Ann', PHONE: '+100', SECRET: 'x' }

// Keep only what the next call needs
pick(contact, ['ID', 'NAME']) // { ID: '42', NAME: 'Ann' }

// Drop an internal field before logging
omit(contact, ['SECRET']) // { ID: '42', NAME: 'Ann', PHONE: '+100' }
```

Resolve a raw field type to a `DataType` member:

```ts
import { getEnumValue, DataType } from '@bitrix24/b24jssdk'

getEnumValue(DataType, 'string') // DataType.string
getEnumValue(DataType, 'nope')   // undefined
```

Branch on array shape with a type guard:

```ts
import { isArrayOfArray } from '@bitrix24/b24jssdk'

isArrayOfArray([[1, 2], [3, 4]]) // true  — array of arrays
isArrayOfArray([1, 2, 3])        // false — flat array
isArrayOfArray([])               // false — empty array
```

## Alternatives and Recommendations

- **Use `getEnumValue` with the enums in [`types/common`](https://bitrix24.github.io/b24jssdk/raw/docs/working-with-the-rest-api/types-common.md).** It pairs naturally with [`DataType`](https://bitrix24.github.io/b24jssdk/raw/docs/working-with-the-rest-api/types-common.md) and any other SDK enum when you need to validate a raw REST string before treating it as a typed value.
- **Prefer `pick` / `omit` for small, explicit reshaping.** They are shallow by design; for deep cloning or complex transforms reach for a dedicated utility rather than layering these.
- **`isArrayOfArray` is a heuristic, not a validator.** It trusts the first element to represent the whole array — do not use it to validate mixed or untrusted input where later elements may differ in shape.
- **Runtime type guards for scalar values live in [`Type`](https://bitrix24.github.io/b24jssdk/raw/docs/working-with-the-rest-api/tools-type.md).** `isArrayOfArray` answers one narrow question about array nesting; use `Type`'s guards (`isArrayFilled`, `isStringFilled`, …) for general shape checks.

## Sitemap

See the full [sitemap](/b24jssdk/sitemap.md) for all pages.
