字符串的定义与比较
作者:
Leophen | 来源:发表于
2018-12-06 10:08 被阅读0次<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>字符串的定义与比较</title>
<script type="text/javascript">
var a = new String('haha'); //创建新的对象
var b = new String('haha'); //创建新的对象
var c = String('haha'); //直接返回haha
var d = 'haha'; //直接返回haha
alert(a==b); //结果为false
alert(c==d); //结果为true
alert(a==c); //结果为true
alert(b==d); //结果为true
alert(String(a)==String(b)); //结果为true
</script>
</head>
<body>
</body>
</html>
本文标题:字符串的定义与比较
本文链接:https://www.haomeiwen.com/subject/jdencqtx.html
网友评论