conductor
Why I'm building conductorGitHub
v1.5.0
v1.5.0
  • Introduction
  • Overview
    • Introduction
    • Core concepts
  • API reference
    • always
    • append
    • apply
    • arity
    • branch
    • capitalize
    • compose
    • concat
    • curry
    • curryN
    • delay
    • dump
    • entries
    • equals
    • equalsBy
    • factory
    • filter
    • findIndex
    • flatten
    • flip
    • forEach
    • get
    • head
    • ifElse
    • identity
    • into
    • isPromise
    • iterate
    • join
    • keys
    • map
    • merge
    • mergeBy
    • next
    • not
    • pluck
    • prepend
    • random
    • reduce
    • replace
    • slice
    • some
    • split
    • take
    • then
    • toLowerCase
    • transduce
    • transformers
      • transformers/filter
      • transformers/map
    • type
    • upsert
    • values
  • Guides
    • example use cases
    • checkGuards
Powered by GitBook
On this page
  • description
  • example
  1. API reference

replace

replace :: (Number index, Any value, Array input) => Array output

description

Returns a new array after replacing the value at the provided index with the provided value in the input array. If the index is not found, the input array is simply (shallow) cloned.

Like nearly all methods in conductor, replace is a pure function and will not modify the input array.

Like nearly all methods in conductor, replace is a pure function and will not modify the input array.

example

import { replace } from 'conductor'

const numbers = [3, 1, 1]
replace(2, 4, numbers) // [3, 1, 4]

Here, we simply replaced the value at index 2 by the value 4.

PreviousreduceNextslice

Last updated 7 years ago