Reitter: Answering the question: "How do I develop an app for GNOME?"
Posted Feb 5, 2013 19:39 UTC (Tue) by
khim (subscriber, #9252)
In reply to:
Reitter: Answering the question: "How do I develop an app for GNOME?" by oldtomas
Parent article:
Reitter: Answering the question: "How do I develop an app for GNOME?"
JavaScript's core is fine, but it was frozen too early.
Not even close.
> test = Array(8, 9, 10)
[8, 9, 10]
> test.sort()
[10, 8, 9]
Looks logical? Let's fix it:
> test.sort(function(a,b){return a-b})
[8, 9, 10]
Cool. What about strings?
> test = Array("8", "9", "10", "b", "a")
["8", "9", "10", "b", "a"]
> test.sort(function(a,b){return a-b})
["8", "9", "10", "b", "a"]
Hmm... That's strange. Looks like we'll need to check types of variables. Can we at least compare few variables?
> a = 10
10
> b = "11"
"11"
> c = "9"
"9"
> a < b
true
> b < c
true
> c < a
true
Apparently not. Can we at least compare two?
> a = "a"
"a"
> b = 10
10
> a <= b
false
> b <= a
false
Looks like the answer is still "not".
And final example.
test = "Hello"
"Hello"
j = 0; for (i in test) j+=i; j
"001234"
Can you understand WFT goes on here and why the following fix works?
j = 0; for (i in test) j-=-i; j
10
PHP is known as fractal of bad design but JavaScript is close second. It's not even close to scheme in this regard: scheme is sane language JavaScript and PHP are not.
(
Log in to post comments)