vlt / docs

  • PricingBenchmarks (opens in new window)Community (opens in new window)Feedback
  • Overview
    • Overview
    • Reference
  • Usage
  1. Client
  2. /
  3. API Reference
  4. /
  5. @vltpkg/dot-prop

@vltpkg/dot-prop

dot-prop

@vltpkg/dot-prop

A library that allows you to easily access, set, delete, and check deeply nested properties in objects and arrays using string-based paths.

Usage

JavaScript
const obj = { foo: { bar: [1, 2, 3] } }

// Get a value
get(obj, 'foo.bar[0]') // 1

// Set a value
set(obj, 'foo.bar[1]', 42) // obj.foo.bar[1] is now 42

// Delete a value
del(obj, 'foo.bar[2]') // Removes obj.foo.bar[2]

// Check if a path exists
has(obj, 'foo.bar[0]') // true

PreviousReferenceNextReference

On this page

  • Usage

Deploy your package on vlt.io

Publish scoped and private packages, manage organizations and access, and give every developer and CI environment a consistent source for public and private JavaScript dependencies.

Publish now