DEV Community

Miguel Ramirez
Miguel Ramirez

Posted on

Javascript [array methods] - fill

const items: any[] = [1,2,3,4]

const fillled1 = items.fill(1,2,4)
console.debug(`filled from 2 to 4: ${fillled1}`)
const fillled2 = items.fill(1,1)
console.debug(`filled from 1: ${fillled2}`)
const filled3 = items.fill("s")
console.debug(`filled from 0: ${filled3}`)
Enter fullscreen mode Exit fullscreen mode

result:

[DBG]: "filled from 2 to 4: 1,2,1,1"
[DBG]: "filled from 1: 1,1,1,1"
[DBG]: "filled from 0: s,s,s,s"

Top comments (0)