JavaScript能代替php吗?

Is JavaScript able to substitute php?

我有一个开始学习网站开发的朋友,他现在 php。我那边开始学习了Javascript。他问我可不可以完全用JS代替php代码?

嗯,我开始学习 JS 是因为有人告诉我,它可以用于前端、后端(通过 NodeJS)和数据库(通过 MongoDB)。虽然, 由于我是这个领域的初学者, 我不确定答案, 但我还是很感兴趣, 所以我问你: 这可能吗?

He asked me if it's possible to use JS instead of php code entirely?

是的,完全有可能。有几个服务器端 JavaScript 选项。可能最著名的是NodeJS (usually, but not necessarily, plus Express). But Microsoft has always supported JScript (their dialect of JavaScript) in classic ASP, you can use JavaScript in the Java JVM (via Rhino or Nashorn) and thus use JavaScript in servlets, for years there was SilkJS (built on Google's V8) and now there's its successor DecafJS(建立在JVM上)等