LoginSignup
1
0

【JavaScript】Type Castingとは

Posted at

Type Castingとは

型変換 (または型キャスト) とは、あるデータ型から別のデータ型へのデータの転送を意味します。

let a;
let b;
let c;
let d;

a = Number("3.14"); //数値に変換
b = String(3.14);   //文字列に変換
c = Boolean("");    //真偽値に変換
d = Boolean("pizza");

console.log(a, typeof a); //3.14 'number'
console.log(b, typeof b); //3.14 string
console.log(c, typeof c); //false 'boolean'
console.log(d, typeof d); //true 'boolean'
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0