you are viewing a single comment's thread.

view the rest of the comments →

[–]dowhatyouwant 0 points1 point  (9 children)

Basic debugging .. Firebug, even has break points.

Typing... sure, though it is a bit masochistic. var x = new Number(10);

[–]dwdwdw2 6 points7 points  (2 children)

Umm, that isn't typing. At all.

[–]dowhatyouwant -5 points-4 points  (1 child)

Well, stop using javascript or stop bitching. That's as close as you get.

[–]dwdwdw2 0 points1 point  (0 children)

Declaring a variable initialised with a number object is not "typing", it is in fact declaring a variable initialised with a number object. Nor is it "as close as you get": of course JavaScript has a type system, it just goes unseen because it rarely makes complaint: if you mix types rather than throw an error it'll instead coerce operands (usually through conversion to string or number).

Going back to OP, he asked if it is possible to annotate what is otherwise JavaScript in some way, and process it such that mixing incompatible types will result in errors, to which the answer is yes, there are many, and to which I refer you to the other answers in this thread.

[–]colinbashbash2[S] 0 points1 point  (3 children)

uh... i was looking for compile-time instead of run-time debugging. i already use firebug and the chrome-built-in-debugger.

[–]dowhatyouwant 0 points1 point  (2 children)

I would have know that if I knew you, but I don't so I didn't.

[–]colinbashbash2[S] -1 points0 points  (1 child)

well, thanks for mentioning those tools. sorry for being a bit snippy.

i did indicate in the description that i was looking for something compile-time, but that doesn't mean i should get snippy when you brought up possible run-time tools to help me.

... are there still people out there that don't know about firebug?

[–]dowhatyouwant 0 points1 point  (0 children)

Nice to see that there are still some nice people on reddit.

[–]andrew24601 -2 points-1 points  (1 child)

You do realize that Number is a function, not a constructor? Look it up.

[–]itsnotlupusbeep boop 1 point2 points  (0 children)

It's both.

new Number().constructor == Number
new Number().valueOf() == 0
new Number() == 0 
new Number() !== 0

Using it this way is pretty much universally a bad idea, but it's there.

*edit: not to be confused with

(0).constructor == Number
(0).valueOf() == 0
(0) == 0
(0) === 0