BFE.dev solution for JavaScript Quiz
113. push

Array.prototype.push returns the new length of the array.

const a = [1,2,3]
const b = a.push(4) // new length is 4, so b is 4
const c = b.push(5) // there is no `push()` method on Number so Error(TypeError) is thrown
console.log(c)

Below is the detailed spec

  1. Let O be ? ToObject(this value).
  2. Let len be ? LengthOfArrayLike(O).
  3. Let argCount be the number of elements in items.
  4. If len + argCount > 2 ^ 53 - 1, throw a TypeError exception.
  5. For each element E of items, do a. Perform ? Set(O, ! ToString(𝔽(len)), E, true). b. Set len to len + 1.
  6. Perform ? Set(O, "length", 𝔽(len), true).
  7. Return 𝔽(len).
You might also be able to find a solution fromcommunity posts or fromAI solution.