For (var i = 10; --i >= 1; ) doesn't work in the javascript engine


#1

If you change

for (var i = 1; i < 10; ++i)

to

for (var i = 10; --i >= 1; )

in the javascript demo,

you get error "Line 19, column 25 : Found ')' when expecting an expression"


#2

Thanks - fixed now!


#3

Thanks,

could we possibly have Math.floor and Math.ceil implemented as well?


#4

Sure, I'll add those when I get a moment.


#5

Thanks for the roof and floor

Two more things, in Javascript semicolon is only neccessary between statements if they're on the same line, its therefore fully legitimate to write code like

for (var i = 10; --i >= 0;)
{
    Demo.print (i / 10)  // no semi needed here
}

Moreover, this code is expected to output a series of decimal numbers, 0.9 0.8 0.7  ..  0.1 0. Which it doesn't. It produces only ten zeroes.

It seems there is some form of integer arithmetics going on here. As far as I know, javascript doesn't have integers. Only floating point numbers.


#6

Ok, I've sorted out the integer division thing.

Sigh.. parsing the newlines without semicolons will be a pain - no time to do that right now, but thanks for the heads-up.


#7

Well I guess most of us can live with the semicolon issue. After all, you get a verbose slap on your fingers for every "missing" semi which will help you toe the line...