我想在JavaScript中使用面向对象编程技术,但我无法从一个类访问另一个类的方法。怎样才能像下面这样呢?classone{write(){console.log("Yes!Idid!");}}classtwo{varobject=newone();tryingMethod(){object.write();}}我收到以下错误:UncaughtSyntaxError:Unexpectedidentifier-->>forvarobject=newone(); 最佳答案 您的语法不合法。您的控制台中应该有一个错误,向您显示哪一行代码