Last active
September 1, 2019 06:12
-
-
Save ThomRoman/a9e86ac6dd012b93fa6cf72c8b471771 to your computer and use it in GitHub Desktop.
Data Structures
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const printFullName_1 = <T extends {name:string,lastName:string}>(obj:T)=>({ | |
...obj, | |
fullName:`${obj.name} ${obj.lastName}` | |
}) | |
interface IPerson{ | |
name:string, | |
lastName:string | |
} | |
const printFullName_2 = <T extends IPerson>(obj:T)=>({ | |
...obj, | |
fullName:`${obj.name} ${obj.lastName}` | |
}) | |
const thom = printFullName_1({ | |
name:'Thom', | |
lastName:'Roman' | |
}) | |
console.log(thom) | |
class Queue<T>{ | |
private data | |
constructor(){ | |
this.data = [] | |
} | |
push(item:T){ | |
this.data.push(item) | |
} | |
pop(){ | |
this.data.shift() | |
} | |
} | |
const queue = new Queue(number) | |
queue.push(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment