Skip to content

Instantly share code, notes, and snippets.

@ThomRoman
Last active September 1, 2019 06:12
Show Gist options
  • Save ThomRoman/a9e86ac6dd012b93fa6cf72c8b471771 to your computer and use it in GitHub Desktop.
Save ThomRoman/a9e86ac6dd012b93fa6cf72c8b471771 to your computer and use it in GitHub Desktop.
Data Structures
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