在JavaScript中也玩变量类型强行转换时间:2024-08-25 12:36:32<script language="javascript"> var str = '100'; var num = Number(100); alert(typeof(num) + ': ' + num); var obj = Object(str); alert(typeof(obj) + ': ' + obj); var bool = Boolean(str); alert(typeof(bool) + ': ' + bool); var num = 100; var str = String(num); alert(typeof(str) + ': ' + str); var bool = Boolean(num); alert(typeof(bool) + ': ' + bool); var obj = Object(num); alert(typeof(obj) + ': ' + obj); var bool = true; var str = String(bool); alert(typeof(str) + ': ' + str); var num = Number(bool); alert(typeof(num) + ': ' + num); var obj = Object(bool); alert(typeof(obj) + ': ' + obj); var obj = {}; var str = String(obj); alert(typeof(str) + ': ' + str); var num = Number(obj); alert(typeof(num) + ': ' + num); var bool = Boolean(obj); alert(typeof(bool) + ': ' + bool); </script>