Skip to content

Instantly share code, notes, and snippets.

@bonomiandreia
Last active March 8, 2022 13:58
Show Gist options
  • Save bonomiandreia/89d5f3d3f808220a618a125db8ba7a1e to your computer and use it in GitHub Desktop.
Save bonomiandreia/89d5f3d3f808220a618a125db8ba7a1e to your computer and use it in GitHub Desktop.
add a line to a object
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