Is there any way to program in JavaScript with C# like syntax? I’m new to js and can’t figure it out and it’s frustrating.
TypeScript more closely resembles C#, but it’s still mostly the same as JavaScript. If you learned C#, I have no doubt that you can learn JavaScript.
You can use Typescript, which is a typed superset of JS written for Microsoft by the designer of C#. However, it is still JS underneath and works the same way. Note that JS/TS is not C# and the version of OO does not work the same way despite it resembling it syntax-wise; JS has free functions & fully supports a functional style along with many things. If you try to blindly import the OO patterns use when writing C# programs, you will normally end up producing terrible JS code.
You can also use C# to write front end apps using Blazor (it compiles a .Net runtime to WASM letting you just write the app in C#).
Typescript has structural subtyping, so one rarely has to use classes, just interfaces and types. It ends up with a very different style as a result. Angular is an exception, preferring to use classes for almost everything.
Hey there @alfreps1990!
All the others have already recommended TS so I won’t do that, but I will give you some advice. Don’t just look for alternatives because you can’t understand JS, it might come back to bite you later. Having to grind through a language is part of programming and looking for shortcuts in learning is like looking for shortcuts while building a house.
The house may stand when it’s bright and sunny but when the hurricane comes will the house stand?
Hope this helped!
Best,
Cy499_Studios
Thanks everyone for your advice, I’ll try with TS, but I will keep on learning JS. @Cy499_Studios, you made it very clear
TS is JS so you can’t avoid learning JS.
I can see how some of the TS syntax might feel more familiar to someone coming from C# but I’m not so sure if it’s the best way to learn JS though.
@alfreps1990, No problem!
Thatt’s why we’re here!
Feel free to ask any more questions to the forum!
Best, Cy499_Studios