how to use generics in javascript code example
Example 1: typescript generic type
function identity<T>(arg: T): T {
return arg;
}Try
Example 2: how to make a generic variable in javascript
var x = 1;
var y = 1;
if (x == y) {
x = x + 1
}
function identity<T>(arg: T): T {
return arg;
}Try
var x = 1;
var y = 1;
if (x == y) {
x = x + 1
}