Browse Source

4.4: default parameter values.

Frederic G. MARAND 5 years ago
parent
commit
8980938f59
1 changed files with 7 additions and 0 deletions
  1. 7 0
      app/app.ts

+ 7 - 0
app/app.ts

@@ -48,3 +48,10 @@ bar(1, 2, 3, 4, 5); // (5+6)/2 = 15
 // Rejected because of noImplicitAny.
 // function qux(x, y) { return x + y; }
 // qux('a', 'b');
+
+function sendGreeting(greeting: string = "Hello, world"): void {
+  console.log(greeting);
+}
+
+sendGreeting();
+sendGreeting("Hello, moon");