summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAlbert <87888006+MustCodeAl@users.noreply.github.com>2024-05-14 21:34:54 -0500
committerGitHub <noreply@github.com>2024-05-14 20:34:54 -0600
commit69f7f5d856a1073be6d5adbad811483c4d0ba4f7 (patch)
tree23d822e32a9e38e83c70ea884aad55094590df0f
parent07b055e8f104ff83e26f426f75ee6dbfba3260cd (diff)
[typescript/en] multiple types (#4803)
-rw-r--r--typescript.html.markdown5
1 files changed, 5 insertions, 0 deletions
diff --git a/typescript.html.markdown b/typescript.html.markdown
index f8e78d44..24d1db10 100644
--- a/typescript.html.markdown
+++ b/typescript.html.markdown
@@ -72,6 +72,11 @@ let f4 = (i: number) => { return i * i; }
// keyword needed
let f5 = (i: number) => i * i;
+// Functions can accept more than one type
+function f6(i: string | number): void {
+ console.log("The value was " + i);
+}
+
// Interfaces are structural, anything that has the properties is compliant with
// the interface
interface Person {