|
|
|
|
|
by klodolph
2375 days ago
|
|
My experience is different. I write a decent amount of JS code each year and try to catch up with current best practices where I can, but every year it’s been a bit of a pain to write any code that’s shared between browser and client. Various ES features will have different levels of support in different layers, and this is especially tough once you take into account the various transpilers or polyfills, and the big sticking points for me over the past two years have been ES imports and async (shockingly, with backend support lagging). These days my main strategy is to have three TypeScript projects—frontend, backend, and common. I then whitelist imports in the common libraries. > It's the same language, using the same JavaScript engine (v8 for chrome). I find it completely unacceptable to assume that V8 is running in the browser. In general, I do all of my JS development work in Firefox or Safari, and this saves me a bunch of time checking portability later. |
|
New features will have varying support between implementations in any language. You have to take these differences into account even if you're writing frontend-only code.
> I find it completely unacceptable to assume that V8 is running in the browser. In general, I do all of my JS development work in Firefox or Safari, and this saves me a bunch of time checking portability later.
The point is it can be the same javascript engine for frontend and backend. The difference between Node JS and Firefox JS is the same as between Chrome JS and Firefox JS.