javascript nameof
// TypeScript
// NameOf.ts
export const NameOf = <T>(name: keyof T) => name;
// Setup
class User {
Name: string;
Age: number;
}
// Usage
import {NameOf} from './NameOf';
function UseNameOf() {
console.log(NameOf<User>('Name'));
}
// The benefit is that, event though it's still technically
// a string, TypeScript provides code completion when writing
// that string. I.e., when you start typing a property of User,
// is suggests 'Name' and 'Age'.
Also in JavaScript:
- android studio react native plugins
- blur javascript
- js find index in list
- javascript how-do-i-remove-a-property-from-a-javascript-object
- how to align text inside react component
- angular limit string length
- get ckeditor textarea value in jquery
- how to add okta api to vuejs
- forjs check if key in json
- javascript link to another page
- ready function jquery
- get page link angular
- discord.js rich embed
- angular event emitter
- javascript round to 2 digits
- check if not checked vanila js
- javascript get a random number with 6 digits
- how to create json file in c#
- javascript change attribute
- definicion de un componente en angular
- react native expo change color android navigation bar
- dwhdjksbhds efedhgsd djsioqdhsjd
- get uislider
- react hooks update nested object