Comment

Comment by teo_zero

I'm going through the handbook and some things don't seem satisfactory.

Division always yelds a floating-point number, so the following doesn't work, you have to explicitly use floor():

  min = time / 60
  sec = time % 60
Also

  var x = [1, 2, 3]
  x[1] /= 2
It's weird that now x includes one float and 2 integers. Besides, x[1] == 1 evaluates to false because a float never equals an integer.

The description of 'for' loops is not complete. For example, does range(1, 10) go from 1 to 10 or from 1 to 9? What is the value of the iteration variable after exiting the loop?

The example to handle a variable number of arguments calls the function callee() with 0 to 4 arguments. So it IS possible to have functions with a variable number of parameters. What's the goal of this example, then?

parent teo_zero 3 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton