#author("2024-03-11T09:27:20+00:00","default:iseki","iseki") #author("2024-03-11T09:27:55+00:00","default:iseki","iseki") * TypeScript [#u02d6bd1] ** TypeScript とは - JavaScript にクラスの概念や,(コンパイラ風)文法チェックを無理やり導入したもの. - そのため,JavaScriptに比べて制限がかかる. - 最終的に,JavaScriptに変換されて実行される. ** Debug *** プロパティ(変数)一覧 [#y92c94c4] let keyArray = Object.keys(user); keyArray.forEach(function(element){ console.log(user[element]); }); for (const key in obj) { console.log(String(key) + " -> " + obj[key]); } *** メソッド(関数)一覧 [#sb9c4efb] - https://qiita.com/suin/items/b807769388c54c57a8be const getMethods = (obj: object): string[] => { const getOwnMethods = (obj: object) => Object.entries(Object.getOwnPropertyDescriptors(obj)) .filter(([name, {value}]) => typeof value === 'function' && name !== 'constructor') .map(([name]) => name) const _getMethods = (o: object, methods: string[]): string[] => o === Object.prototype ? methods : _getMethods(Object.getPrototypeOf(o), methods.concat(getOwnMethods(o))) return _getMethods(obj, []) } *** 上記をまとめた関数 [#fb25e0d3] function disp_obj(obj: object) { const getMethods = (obj: object): string[] => { const getOwnMethods = (obj: object) => Object.entries(Object.getOwnPropertyDescriptors(obj)) .filter(([name, {value}]) => typeof value === 'function' && name !== 'constructor') .map(([name]) => name) const _getMethods = (o: object, methods: string[]): string[] => o === Object.prototype ? methods : _getMethods(Object.getPrototypeOf(o), methods.concat(getOwnMethods(o))) return _getMethods(obj, []) } console.log("+++++++++++++++++++++++++++++++++++"); for (const key in obj) { console.log(String(key) + " -> " + obj[key]); } console.log("==================================="); console.log(getMethods(obj)); console.log("+++++++++++++++++++++++++++++++++++"); }