'How to find if a method belongs to super or - Extending Array and Testing with ES6

I'm new to OOP in ES6 and trying to understand how to extend Array so i can create pipelines. I'm starting with a simple case of extending Array ad overriding Array.filter, and expecting result.hasOwnProperty("filter") to be true... but it's not:

So how do you test that the method filter now lives in the Wordlist class?

export class Wordlist extends Array{
  constructor(...args){
    super(...args)
  }

  filter(...args){
    console.log("filtering")
    return super.filter(...args)
  }
}

// test
describe.only('Wordlist.filter', ()=>{
  it('should filter an array', ()=>{
    const wordlist = new Wordlist('hello', 'rhubarb')
    const result = wordlist.filter(word => word === 'rhubarb')

    expect(result.length).toEqual(1) // pass
    expect(result).toEqual(["rhubarb"]) // pass
    expect(result.hasOwnProperty('filter')).toBe(true) // should pass but doesnt!!! 
    expect(result.hasOwnProperty('reduce')).toBe(false) // passes
  })
})


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source