i can't figure it out on how to get the values of a static method of a class. my code is below.
class Field {
constructor(rows = 11, cols = 10) {
this.numRows = rows
this.numCols = cols
}
static loadFromFileContents(contents) {
this.numCols = contents.split('x')[0]
this.numRows = contents.split('x')[1]
}
}
const contents = `4 x 5`
const field = Field.loadFromFileContents(contents)
console.log(field.numCols)
console.log(field.numRows)
first of all, i want to get the instance of the static method. something like this instanceof(field), it should be equal to 'Field'. but i don't know if my syntax is correct for getting the instance. Second i want the return value of field.numCols should be equal to 4 because of the first split value and
field.numRows should be equal to 5. sorry i'm not that familiar with static method of a class. i hope you can help me with my problem. thank you so much.