サンプル集  >  Node.js  >  typeof
typeof
2025/08/24

typeofを使ってみます。

◆環境
OS Windows 10 Home 22H2 64bit
Node.js 22.18.0

ymwnj003-main.js
 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
14: 
console.log(typeof 'Hello Node.js!!')

console.log(typeof 123);

console.log(typeof true);

const js = JSON.stringify({ a: 1, b: 2});
console.log(typeof js);

const ar1 = ['one''two''three'];
console.log(typeof ar1);

const ar2 = { one: 1, two: 2, three: 3};
console.log(typeof ar2);

実行してみます。

node .\ymwnj003-main.js
string
number
boolean
string
object
object

正常に動作しました。

▲ PageTop  ■ Home


Copyright (C) 2025 ymlib.com