当前第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怎么强制转换成整型的详细内容,更多文章请关注木庄网络博客!
返回前面的内容
相关阅读 >>
通过代码示例,了解css3+javascript按钮水波纹效果
javascript中new是什么意思
javascript url怎么隐藏
理解并优化javascript代码
javascript 中向上取整、向下取整、四舍五入的操作
javascript如何禁止文字的复制
javascript中的arguments对象的用法介绍
详解javascript里的await/async的作用和用法
javascript中split和join的区别
javascript主要的循环有哪些
更多相关阅读请进入《javascript》频道 >>
人民邮电出版社
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者
转载请注明出处:木庄网络博客 » javascript怎么强制转换成整型