You're shadowing your Matrix
identifier in the declaration by doing this:
const sigmoid = function(A, flag = false, factor = 1, Matrix = Matrix) {
// ---------------------------------------------------^
That means the Matrix
after the =
is the parameter, not the class identifier.
Just use a standard lower-case parameter name instead:
const sigmoid = function(A, flag = false, factor = 1, matrix = Matrix) {
// ---------------------------------------------------^