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 |
/* alertでconsoleの内容が見たい */ const main = () => { let buf: string = ""; const p = (arg: any) => { if ("object" === typeof arg) { arg = JSON.stringify(arg); } buf += arg += "\n"; console.log(arg); }; const disp = () => { alert(buf); }; const sub = () => { const a = { あ: "a", い: "i" }; p('"hello" : ' + "hello"); p("123 : " + 123); p("typeof a : " + typeof a); p("a : " + a); p(a); }; sub(); disp(); }; main(); |
1 2 3 4 5 |
"hello" : hello 123 : 123 typeof a : object a : [object Object] {"あ":"a","い":"i"} |