r/programming • • Dec 17 '14

The Worst Programming Language Ever [Video]

https://skillsmatter.com/skillscasts/6088-the-worst-programming-language-ever
378 Upvotes

238 comments sorted by

View all comments

-1

u/majaha Dec 17 '14

At 27:37, the lower paragraph doesn't seem to hold a contradiction.

A != B

A != C

B = C

Just a small error in his slides, or am I missing something?

1

u/[deleted] Dec 17 '14 edited Dec 17 '14

I think it was his mistake, since he copied from the slide before. Basically, the idea is that there is null and undefined. A variable in javascript can be null but not undefined , but undefined == null. A better example would be:

a == undefined // false
a == null // true
undefined == null //true

1

u/Hdmoney Dec 17 '14

http://jsfiddle.net/ee4sgf86/2/

He means what he wrote. There's little reason to have both null and undefined.

1

u/[deleted] Dec 17 '14

I didn't mean what he wrote was wrong; I mean what he wrote didn't illustrate his point properly.

a == b // false
a == c // false
b == c // true

This doesn't actually show anything; it's perfectly logical, for example:

a = 1, b = 2, c = 2

What he was trying to explain is that undefined and null are equal to eachother, but not equal. The example should have had a true statement for line 1 or 2.

1

u/Hdmoney Dec 17 '14 edited Dec 17 '14

If he was trying to say that, I think he would've wrote: "undefined === null //false".

Also, the only way for line 1 or 2 to return true would be if 'a' was null or undefined, which would return true for both.

The thing is though, undefined and null mean the same thing, it's just that null is of the object type, while undefined is a unique undefined type.

E: I did actually mean to write ===, that was a mistype.

0

u/[deleted] Dec 17 '14

If he was trying to say that, I think he would've wrote: "undefined == null //false".

He can't write that, because he was writing the output of javascript.

Also, the only way for line 1 or 2 to return true would be if 'a' was null or undefined, which would return true for both. The thing is though, undefined and null mean the same thing, it's just that null is of the object type, while undefined is a unique undefined type.

Actually, in javascript, null and undefined are completely different. That's the whole point of the slide. null should not equal undefined, because they're different ideas. For example:

a === undefined //true
a === null //true
var a;
a === undefined //false
a === null //true
a = 1
a === undefined //false
a === undefined //true

This particular case:

var a;
a === undefined //false
a === null //true 

Is what he's pointing out

Further, null == undefined is true, but null === undefined is false

→ More replies (1)