I came across an interview question today, but I didn't figure out how to solve it.

var a1 = new A();
console.log(a1.val); //1
var a2 = new A();
console.log(a2.val);//2

I was thinking of using closures, but I didn"t write them. Can anyone help me to answer them?

Dec.22,2021


function A(){
    this.val=A.prototype.valPP
}
A.prototype.val=1
let a1=new A()
let a2=new A()
console.log(a1.val, a2.val)
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eae1b7-21ac.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eae1b7-21ac.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?