pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/Wcoder547/typeScript/commit/83b3dab8541178f94bdd46e64df27778dd110ed5

rigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/global-7a1ad343bd40328c.css" /> add generics basic · Wcoder547/typeScript@83b3dab · GitHub
Skip to content

Commit 83b3dab

Browse files
committed
add generics basic
1 parent 0422d40 commit 83b3dab

2 files changed

Lines changed: 60 additions & 0 deletions

File tree

Generics/myGenerics.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log("HELLO WORLD");

Generics/myGenerics.ts

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
console.log("HELLO WORLD");
2+
3+
const score: Array<number> = [1, 2, 3, 4, 5];
4+
const names: Array<string> = ["waseem", "fahad", "talha"];
5+
6+
function identityOne(val: boolean | number): boolean | number {
7+
return val;
8+
}
9+
10+
function identityTwo(val: any): any {
11+
return val;
12+
}
13+
14+
function identityThree<type>(val: type): type {
15+
return val;
16+
}
17+
identityThree("ok");
18+
19+
function identityFour<T>(val: T): T {
20+
return val;
21+
}
22+
23+
interface bottle {
24+
brand: string;
25+
type: number;
26+
}
27+
28+
// identityFour<bottle>({});
29+
interface database {
30+
connection: string;
31+
usernme: string;
32+
password: string;
33+
}
34+
35+
function anotherFunction<T, U extends database>(val1: T, val2: U): object {
36+
return {
37+
val1,
38+
val2,
39+
};
40+
}
41+
// anotherFunction(3, {});
42+
43+
interface Quiz {
44+
name: string;
45+
type: string;
46+
}
47+
interface course {
48+
name: string;
49+
author: string;
50+
subject: string;
51+
}
52+
53+
class sellAble<T> {
54+
public cart: T[] = [];
55+
56+
addToCart(products: T) {
57+
this.cart.push(products);
58+
}
59+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy