Last active
March 8, 2022 13:58
-
-
Save bonomiandreia/89d5f3d3f808220a618a125db8ba7a1e to your computer and use it in GitHub Desktop.
add a line to a object
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
interface User { | |
id: number, | |
name: string, | |
[key: string]: unknown, | |
} | |
const usertype = { | |
id: 1, | |
name: 'andreia' | |
} | |
function myFunc(object: User, nameObject: string, valueObject: string) { | |
return object[nameObject] = valueObject; | |
} | |
console.log(myFunc(usertype, 'age', '26')) | |
console.log(usertype) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment