Is it possible to call a function from inside the Javascript constructor like this:
class Blockchain {
constructor(genesisBlock) {
this.blocks = []
addBlock(genesisBlock)
}
addBlock(block) {
if(this.blocks.length == 0) {
block.previousHash = "0000000000000000"
}
}
}
I get the following:
addBlock is not defined
this.addBlock(genesisBlock)