ການປ່ຽນຮູບແບບ JavaScript

ຕາລະລາງຮູບແບບ JavaScript

ຕາລະລາງນີ້ສະແດງວ່າການປ່ຽນມາຮູບແບບ Number、String ແລະ Boolean ຂອງຄູ່ມູນ JavaScript ທີ່ຫຼາກຫຼາຍ

ຄູ່ມູນຕົ້ນ ການແປງເປັນຈຳນວນ ການແປງເປັນຄຳເວົ້າ ການແປງເປັນຄວາມຈິງ ກວດສອບ
false 0 "false" false ກວດສອບ
true 1 "true" true ກວດສອບ
0 0 "0" false ກວດສອບ
1 1 "1" true ກວດສອບ
"0" 0 "0" true ກວດສອບ
"1" 1 "1" true ກວດສອບ
NaN NaN "NaN" false ກວດສອບ
Infinity Infinity "Infinity" true ກວດສອບ
-Infinity -Infinity "-Infinity" true ກວດສອບ
"" 0 "" false ກວດສອບ
"20" 20 "20" true ກວດສອບ
"twenty" NaN "twenty" true ກວດສອບ
[ ] 0 "" true ກວດສອບ
[20] 20 "20" true ກວດສອບ
[10,20] NaN "10,20" true ກວດສອບ
["twenty"] NaN "twenty" true ກວດສອບ
["ten","twenty"] NaN "ten,twenty" true ກວດສອບ
function(){} NaN "function(){}" true ກວດສອບ
{ } NaN "[object Object]" true ກວດສອບ
null 0 "null" false ກວດສອບ
undefined NaN "undefined" false ກວດສອບ

ເຂົ້າເຫັນ:ຄວາມມູນໃນການນຳໃຊ້ຂອງຄຳວຽນ (" ") ແມ່ນຄວາມມູນຫົວ. ຄວາມມູນສີສີນແມ່ນຄວາມມູນທີ່ຜູ້ຍົກຍ້ອງບໍ່ຕ້ອງການ.

ສຳລັບການຮຽນຂໍ້ມູນການປ່ຽນຮູບແບບ JavaScript ຍັງມີຫຼາຍກວ່າ, ກະລຸນາອ່ານ ການສອນການປ່ຽນຮູບແບບ JavaScript.