Category:Jsish: Difference between revisions

m
spacing and some prose change
m (version update to 2.8)
m (spacing and some prose change)
Line 21:
* Function definitions can use type specifiers and default values.
 
 
While '''Jsish''' can honestly be called a Javascript interpreter, the extensions and differences from standard, form what is, realistically, a different language. For instance:
 
nodejs> [1,2] + [2,1]
"1,22,1"
 
jsish># [1,2] + [2,1];
0
 
Typed parameters for functions also sets Jsi apart from other ECMAScript implementations.
 
prompt$ jsish
Line 33 ⟶ 36:
# function foo (a:number, b:string="ok"):number { return a+1; }
variable
 
/* Demonstrate parameterized types */
# foo('a', 1, 2);
warn: got 3 args, expected 1-2, calling function foo(a:number, b="ok"):number (at or near "a")
warn: type mismatch for argument arg 1 'a': expected "number" but got "string", in call to 'foo' <a>. (at or near "a")
Line 41 ⟶ 44:
warn: type mismatch returned from 'foo': expected "number" but got "string", in call to 'foo' <a1>. (at or near "a")
"a1"
 
# foo(1);
2
#
Anonymous user