Problem when using eval to create a function

It was a complicated code, I simplified it to this

class Wr{
    constructor(w){this.w=w}
}
class E{}
Array.prototype.popfirst=function(){
    this.splice(0,1)
}
function w(){
    let a=["Wr",new E()]
    eval(`var f=function(args){return new ${a[0]}(...args)}`)
    a.popfirst()
    console.log(f)
    console.log(",")
    console.log(...a)
    console.log(",")
    console.log(f(a))
}

I want f(a) to be new Wr(new E()),
but when l checked the console, I saw only one ƒ (){ this.splice(0,1) }. But I used 5 log()!

I fixed the code several times but still don’t understand where the problem is.