当前第2页 返回上一页
示例
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 31 32 33 34 35 36 37 38 39 40 41 42 43 | <!DOCTYPE html>
<html>
<head>
<meta charset= "UTF-8" >
<title>数据类型转换</title>
</head>
<body>
<script>
var count =10;
println( count .toString());
var boolean=true;
println(boolean.toString());
var today= new Date ();
println(today.toString());
var shoppingCart=[ '鞋' , '连衣裙' , '皮带' ];
println(shoppingCart.toString());
var person={};
person.name= 'huangshiren' ;
person.age=58;
person.appetite=3;
person.eat= function (){
document.write( '正在吃饭' );
}
println(person.toString());
function println(a){
document.write(a+ '<br>' );
}
</script>
</body>
</html>
|
转换为布尔类型
Boolean(mix)函数,将任何类型的值转换为布尔值。
示例
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 31 32 33 34 35 36 37 38 39 40 41 42 43 | <!DOCTYPE html>
<html>
<head>
<meta charset= "UTF-8" >
<title>数据类型转换</title>
</head>
<body>
<script>
var count =10;
println(Boolean( count ));
println(Boolean(0));
println(Boolean(4<3));
println(Boolean(null));
println(Boolean( "" ));
println(Boolean(undefined));
var shoppingCart=[ '鞋' , '连衣裙' , '皮带' ];
println(Boolean(shoppingCart));
var person={};
person.name= 'huangshiren' ;
person.age=58;
person.appetite=3;
person.eat= function (){
document.write( '正在吃饭' );
}
println(Boolean(person));
function println(a){
document.write(a+ '<br>' );
}
</script>
</body>
</html>
|
更多编程相关知识,请访问:编程视频!!
以上就是javascript怎么强制转换成整型的详细内容,更多文章请关注木庄网络博客!
返回前面的内容
相关阅读 >>
浏览器的事件循环详解
javascript中dom常用的方法有哪些
javascript的数据类型不包括什么
javascript中如何实现异步编程模式
javascript web workers的构建块及5个使用场景
javascript中日期如何转为时间戳
javascript怎么增加样式
node.js中文件之间的引入教程实例
d3js怎么样
javascript如何删除数组元素
更多相关阅读请进入《javascript》频道 >>
人民邮电出版社
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者
转载请注明出处:木庄网络博客 » javascript怎么强制转换成整型