>mfw people hate javascript
just because you dont get it doesnt mean its shit
I get it and it's shit.
>javashit
>ever
>>53630345
>mfw people post the reddit frog
>>53630345
>hating something
let go of your attachments friends and seek inner bliss
lmao don't try a river frog boy.
>>53630345
>I'll make it so the page content doesn't show up unless you allow scripts from three different domains
>yeah that makes sense
as expected of a frogposter
I understand it, it's awful, but it's on the verge of being great for what it is(a high level language.) One day. One day.
People hate java too even though it's the best language around
>>53630374
/thread
>>53632433
>people use C to make viruses
>therefore C is a bad language
>>53630345
It is a shit language, and you are a shit programmer.
I hate all languages that aren't easy to read/type.
Ruby and Python I like.
>>53630345[1,5,10,20].sort() //[1,10,20,5]
typeof NaN === "number" //true
>not shit
>>53632906
>I don't understand lexicographical ordering
>I don't understand IEEE floating point numbers
How's your 67th version of Fizzbuzz going?
javascript is pretty bad
t
b
h
f
a
m
>>53632948
I understand them just fine. They're still awful design paradigms. I'm a web dev and I work with js everyday, it's still a piece of shit though.
>>53632991
How else should sort be implemented? How would you compare a number and a string?
What type should NaN be then? You do realize that in static languages like C and Java NaN is also a float right?
>>53633020
Make it take a comparator as an argument. If none is provided, sort numerically if the first element of the list is a number, lexicographically otherwise.
>>53633081
So how should it sort [1, "a"]?
And you do know that you can specify a comparator as an argument right? Fucking retarded web devs.
>>53633020
I'll give NaN a pass, but sort should really be based on the type of the array. I realize this isn't possible given the way javascript is written, but that's the problem. Since it's untyped it's a bitch to debug and leads to horrible design patterns like === and general unexpected behavior.
Some other fun ones:var i = "1"; i++; //11
var i = "1"; i+=1; //2
[] == false //true
![] == false //true
!![] == false //false
I would be no means call it a "good" language. It serves it's purpose, nothing more.
>>53633081
sort can take a compare function as an argument
>implying that there are languages in use today that have no design flaws
>implying that you can't avoid the bad parts of a language
>implying you could design a better language in 10 days (which is what Brendan Eich did it in)
>implying that all other relevant languages didn't get lambdas and other features because Javascript made them popular
>implying that people who "hate" Javascript don't just hate trying to interact with the DOM which is the worst API ever designed
>implying Javascript's inclusion in browsers and the discovery of AJAX in 2005 isn't the reason we're still using the web instead of some abominable Adobe Coldfusion/Flash or Microsoft .NET application delivery system
>implying Javascript is a bad language
Just learn the language and maybe you won't be shit at it.
>>53632906
>[1,5,10,20].sort() //[1,10,20,5]
What the ever-loving fuck??? I can accept most shit in JS but this is straight-out faulty behavior.
>>53632906
>>53633278
And yet['banana', 'melon', 'apple', 'steak'].sort();
//[ 'apple', 'banana', 'melon', 'steak' ]
makes perfect sense
The .sort() function defaults to sorting by unicode, and assumes that all array elements are strings.
If you want to sort numerically, you pass a sorting function as a parameter. Yes lambda functions and functions as first class objects are pretty neat language features.[2,10,20,4].sort(function (a,b) {
return a - b;
});
// [ 2, 4, 10, 20 ]
In terms of examples of why Javascript is shit, this is a pretty dumb example. It just illustrates how people don't know what they're talking about.
Here, at least next time use some decent examples:
https://www.youtube.com/watch?v=2pL28CcEijU
>>53633178
>>53633193
I realize, I was just giving my opinion on what the function should do. If an array has [1, "a"], just let it error unless a comparator was provided.
>>53633629
>lambda functions are a pretty neat language feature
Oh, huh, I never experienced those, except in:
Common Lisp
Scheme
Python
C/C++
Emacs Lisp
Java
...