Skip to content

bugs in {#spread-operator} section #11

Description

@marzelin

function add(...values) {

... token used in a parameter list is called rest parameter


var values = Array.prototype.splice.call(arguments, [1])

should be

var values = Array.prototype.slice.call(arguments),

for following reasons:

  • arguments object shouldn't be modified (splice mutates an object, slice doesn't)
  • call expects a list of arguments, not an array (for arrays there's apply method)
  • add function should add every number given in arguments (slice(0) which equate to slice())

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions