Uncaught TypeError: lib(...).some is not a function

Uncaught TypeError: lib(...).some is not a function

我正在尝试使用对象创建函数原型。

var  lib = function(){
   return true;
};

lib.prototype = {
   some: () => {
      console.log("prototype is called");
   }
}

lib.some();

没用

您必须从 lib 函数定义一个对象并使用它

像这样:

var  lib = function(){
  return true;
};

lib.prototype = {
  some: () => {
     console.log("prototype is called");
  }
}

let a=new lib();

a.some();

或使用新的

var  lib = function(){
  return true;
};

lib.prototype = {
  some: () => {
     console.log("prototype is called");
  }
}

new lib().some();