<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script>
//数据的转换方法
var color=["red","blue"];
console.log(color.toString());//字符串
console.log(color.valueOf());//object
//alert(typeof(color.valueOf()));
console.log(color);
var person1={
toLocaleString:function(){
return "zhangsan";
},
toString:function (){
return "lisi";
}
}
var person2={
toLocaleString:function(){
return "wangwu";
},
toString:function (){
return "zhaoliu";
}
}
var people=[person1,person2];
/*alert(people);
alert(people.toString());
alert(people.toLocaleString());*/
//数组的继承的toLocaleString(),toString(),valueOf()默认用逗号分割
//可以用jion()构建不同的分割字符串
var colors=["red","blue"];
console.log(colors.join("||"));
</script>
</body>
</html>
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报。