<pre>
<!DOCTYPE html>
<html>
<head>
<title>01-三個包裝對象.html</title>
<meta name="keywords" content="keyword1,keyword2,keyword3">
<meta name="description" content="this is my page">
<meta name="content-type" content="text/html; charset=UTF-8">
<meta http-equiv="content-type" content='text/html;charset=utf-8'>
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
<script type="text/javascript">
//三個包裝對象
//java中8大基本數(shù)據(jù)類型都有對應(yīng)的包裝類
//js中五個原始類型,有三個包裝類 =>Number String Boolean
//----------------------------------------------
//java中有自動拆裝箱機制來方便基本數(shù)據(jù)類型的轉(zhuǎn)換,以及包裝方法的調(diào)用
//js 中有偽對象概念 原始類型可以直接調(diào)用對應(yīng)包裝類型的屬性或函數(shù)
//String
//1 創(chuàng)建
//此構(gòu)造和以填寫任意類型數(shù)據(jù)
//構(gòu)造方法擁有強制數(shù)據(jù)類型轉(zhuǎn)換的功能 返回的一定是個string
var str = new String("hello");
// 2 屬性
// alert(str.length);
// alert("world".length);
// 3 方法
//js的String方法分為三類
//一 用來生成標(biāo)簽一般不用
//二
//charAt();
alert(str.charAt(2));
//endwith();返回boolean值 以什么什么結(jié)尾
//substring();
alert(str.substring(0, 5));
//indexof();
//三:有用=>與正則結(jié)合使用
//split();
//replace();
//match();
//search();
</script>
</head>
<body>
This is my HTML page. <br>
</body>
</html>
</pre>
Instanceof運算符
<pre>
<!DOCTYPE html>
<html>
<head>
<title>Instanceof運算符.html</title>
<meta name="keywords" content="keyword1,keyword2,keyword3">
<meta name="description" content="this is my page">
<meta name="content-type" content="text/html; charset=UTF-8">
<meta http-equiv="content-type" content='text/html;charset=utf-8'>
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
<script type="text/javascript">
//Instance of 與java中一樣,用于判斷變量是否屬于指定類型
var str = new String("abc");
alert(str instanceof String);//true
alert("abc" instanceof String);//false "abc"是原始類型 它并不是對象
//僅僅是個偽對象靡努,止咳調(diào)用它的方法和屬性
</script>
</head>
<body>
This is my HTML page. <br>
</body>
</html>
<>