TypeScript
をテンプレートにして作成
[
トップ
] [
タイトル一覧
|
ページ一覧
|
新規
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
* 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 === 'func...
.map(([name]) => name)
const _getMethods = (o: object, methods: string[]): str...
o === Object.prototype ? methods : _getMethods(Object...
return _getMethods(obj, [])
}
*** 上記をまとめた関数 [#fb25e0d3]
function disp_obj(obj: object) {
const getMethods = (obj: object): string[] => {
const getOwnMethods = (obj: object) =>
Object.entries(Object.getOwnPropertyDescriptors(o...
.filter(([name, {value}]) => typeof value ===...
.map(([name]) => name)
const _getMethods = (o: object, methods: string[]...
o === Object.prototype ? methods : _getMethods(Ob...
return _getMethods(obj, [])
}
console.log("+++++++++++++++++++++++++++++++++++");
for (const key in obj) {
console.log(String(key) + " -> " + obj[key]);
}
console.log("===================================");
console.log(getMethods(obj));
console.log("+++++++++++++++++++++++++++++++++++");
}
終了行:
* 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 === 'func...
.map(([name]) => name)
const _getMethods = (o: object, methods: string[]): str...
o === Object.prototype ? methods : _getMethods(Object...
return _getMethods(obj, [])
}
*** 上記をまとめた関数 [#fb25e0d3]
function disp_obj(obj: object) {
const getMethods = (obj: object): string[] => {
const getOwnMethods = (obj: object) =>
Object.entries(Object.getOwnPropertyDescriptors(o...
.filter(([name, {value}]) => typeof value ===...
.map(([name]) => name)
const _getMethods = (o: object, methods: string[]...
o === Object.prototype ? methods : _getMethods(Ob...
return _getMethods(obj, [])
}
console.log("+++++++++++++++++++++++++++++++++++");
for (const key in obj) {
console.log(String(key) + " -> " + obj[key]);
}
console.log("===================================");
console.log(getMethods(obj));
console.log("+++++++++++++++++++++++++++++++++++");
}
ページ名: