일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 |
- custom hook
- java api
- type
- DB2
- TypeScript
- manifest.json
- descendingOrder
- Debug
- react hook
- codewars
- isSquare
- useEffect
- JDBC
- TABLESPACE
- codewar
- IBM
- react
- Today
- Total
목록Concepts/TypeScript (5)
taesik
var names = ['Alice', 'Bob', 'Tiff', 'Bruce', 'Alice']; var countedNames = names.reduce(function (allNames, name) { if (name in allNames) { allNames[name]++; } else { allNames[name] = 1; } return allNames; }, {}); // countedNames is: // { 'Alice': 2, 'Bob': 1, 'Tiff': 1, 'Bruce': 1 }
const sum1=(x:number,y:number)=>{ return x+y; } const sum=(x:number) =>{ return (y:number)=>{ return x+y; } } const sum2= sum(3); console.log(sum2(4)); console.log(sum(3)(4)); curring function : only use 1 parameter and return next function
const out = function ():Function { let cnt=0; let internal =()=> ++cnt; return internal; } const out2 =out(); setInterval(function(){ console.log(out2()) },1000);
const out = function () { let number = 65; let internal =function(){ let char_ = String.fromCharCode(++number); return `${char_}:${number}`; }; return internal; } This return Function. console.log(out()); console.log(out()); result A:65 B:66 const out = function () { let number = 65; let internal =function(){ let char_ = String.fromCharCode(++number); return `${char_}:${number}`; }; return inter..
TypeScript provides several utility types to facilitate common type conversions. These utilities are available globally. Partial It constructs a type that makes all properties of T optional. This utility returns a type representing the set of all subtypes of a given type. interface Todo { title: string; description: string; } function updateTodo(todo: Todo, fieldsToUpdate: Partial) { return { ....