JS Standard LibraryPlaygroundPlayground
GitHubGitHub (opens in a new tab)
  • Introduction
    • arrIns
    • arrReplace
    • arrRm
    • bounds
    • chunk
    • compact
    • countBy
    • diff
    • drop
    • groupBy
    • intersection
    • intersperse
    • max
    • min
    • move
    • range
    • reverse
    • shuffle
    • sort
    • sortBy
    • swap
    • symDiff
    • take
    • union
    • uniq
    • isEmpty
    • isEql
    • isEqlArr
    • isNil
    • isShallowEql
    • aCompose
    • aComposeFn
    • aFilter
    • aForEach
    • aMap
    • aPipe
    • aPipeFn
    • aResolvers
    • hexToRGB
    • rgbToHex
    • compose
    • composeFn
    • noop
    • pipe
    • pipeFn
    • sleep
    • avg
    • clamp
    • divMod
    • isDisjointFrom
    • isEven
    • isOdd
    • isSubsetOf
    • isSupersetOf
    • mean
    • median
    • mode
    • percentage
    • percentageOf
    • prod
    • sum
    • isNegZero
    • isZero
    • toNum
    • clone
    • fromPath
    • get
    • has
    • merge
    • mergeAll
    • omit
    • pick
    • set
    • shallowMerge
    • shallowMergeAll
    • size
    • toPath
    • toSet
    • toUnset
    • unset
    • camelCase
    • capitalize
    • insertAt
    • isEmail
    • pascalCase
    • replaceAt
    • strReplace
    • isArr
    • isArrBuf
    • isAsyFn
    • isBigInt
    • isBlob
    • isBool
    • isDataView
    • isDate
    • isDef
    • isErr
    • isFn
    • isGenFn
    • isInfinity
    • isJSON
    • isMap
    • isNull
    • isNum
    • isObj
    • isPureObj
    • isRegEx
    • isSet
    • isStr
    • isSym
    • isTypedArr
    • isUndef
    • isWkMap
    • isWkRef
    • isWkSet

On This Page

  • Syntax
  • Examples
  • Try
Question? Give us feedback → (opens in a new tab)
String
insertAt

Insert a character or string at the index position.

Syntax

import { insertAt } from '@opentf/std';
 
insertAt(str: string, index?: number, insertStr?: string): string;

Default index = 0

Examples

insertAt() // It throws an error;
 
insertAt('') //=> ''
 
insertAt('', 0) //=> ''
 
insertAt('', 1, 'abc') //=> 'abc'
 
insertAt('a', 0, 'b') //=> 'ba'
 
insertAt('a', 1, 'b') //=> 'ab'
 
insertAt('a', 1, 'bc') //=> 'abc'
 
insertAt('foo baz', 3, ' bar') //=> 'foo bar baz'

Try

capitalizeisEmail

MIT 2024 © Open Tech Foundation.