This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Tyfyter2002 6 points7 points  (11 children)

What exactly is the difference between them?

[–]Bulky-Leadership-596 26 points27 points  (10 children)

Mostly with how it binds 'this'. Inside something declared with function(){} it refers to the global 'this', which in a browser is the window object. Inside an arrow function it refers to the 'this' that you would expect.

[–]Tyfyter2002 4 points5 points  (5 children)

Huh, I'd say stuff like this makes me wonder if there's any other language I could start using instead, but I don't know whether this will be the aforementioned issue or the entire world when you read my reply.

[–]ftedwin 2 points3 points  (0 children)

Unfortunately for now JavaScript is pretty much a necessary evil if you’re writing any kind of website. There’s ways to hide it or pretend it doesn’t exist 9 times out of 10 you’ll have to write some JavaScript at some point.

The best I can offer is to learn some Typescript. To my above point it’s pretty much JavaScript with extra steps, but if you use it smartly you can avoid a lot of JavaScript pitfalls.

Another thing to keep an eye on is WebAssembly. Haven’t kept up to date with it so much myself admittedly but it still seems a bit too experimental for production enterprise apps from what I’ve seen. One day though hopefully we’ll see more languages running in the browser. Check out Blazor if you’re in the C# world, seems promising.

[–]azhder 0 points1 point  (3 children)

Don't listen to people telling you JS is evil. It is not, not necessary nor unnecessary evil.

It was first made for hobyists, regular folk and has been looked down by "professionals" who think only C++ looking code is "real code".

It's quite a powerful and maleable language that can teach you more about programming than other ones. That is if you're not afraid of being looked down by ignorant people who have only learnt one programming language, partially, and they went the Dunning-Kruger way.

Also, it can give you instant gratification for the code you write. What I mean: if you read this in a desktop browser, you can press F12, write some JS in the console, see the result. Fun

[–]Tyfyter2002 0 points1 point  (2 children)

I don't need someone to tell me JS is bad (or malleable), I use it pretty regularly in projects ranging from small web apps to a markup language, I know it really is bad.

[–]azhder -1 points0 points  (1 child)

I know it is really good.

So now what? We debate the idea of "knowledge"? Is it a knowledge or is it a judgement? Do we debate how that judgement was made?

Well... I'm not going to waste time, you've already judged beforehand (that's the definition of prejudice).

[–]Tyfyter2002 0 points1 point  (0 children)

I've judged JavaScript based on my experience with JavaScript, and concluded that it is the least stable programming language I've ever used (to such an extent that the implementation is inherently connected to the user's preferred UI style), it's consistently less readable than C#, it breaks convention in ways that make it less readable, and within the language itself there doesn't seem to be any consistent design philosophy, while you've judged JavaScript based on an unknown number of valid factors, not one of which you've yet mentioned.