From b6c12b85b390190c495a91f69bfe2abd4b7eb8b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=BE=E5=BE=B7=E6=A3=AE?= <1500225483@qq.com> Date: Thu, 27 Oct 2022 05:39:38 +0000 Subject: [PATCH 1/2] =?UTF-8?q?=E6=96=B0=E5=BB=BA=202022=5F10=5F26?= =?UTF-8?q?=E5=8C=85=E8=A3=85=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../2022_10_26\345\214\205\350\243\205\347\261\273/.keep" | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 "47\346\233\276\345\276\267\346\243\256/2022_10_26\345\214\205\350\243\205\347\261\273/.keep" diff --git "a/47\346\233\276\345\276\267\346\243\256/2022_10_26\345\214\205\350\243\205\347\261\273/.keep" "b/47\346\233\276\345\276\267\346\243\256/2022_10_26\345\214\205\350\243\205\347\261\273/.keep" new file mode 100644 index 0000000..e69de29 -- Gitee From 0f7aed8f2b809a0532a7846e1add84c451e48139 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=BE=E5=BE=B7=E6=A3=AE?= <1500225483@qq.com> Date: Thu, 27 Oct 2022 05:39:56 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=E6=9B=BE=E5=BE=B7=E6=A3=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 曾德森 <1500225483@qq.com> --- .../\344\275\234\344\270\232.html" | 52 +++++++++++++++++++ ...6-\345\214\205\350\243\205\347\261\273.md" | 50 ++++++++++++++++++ 2 files changed, 102 insertions(+) create mode 100644 "47\346\233\276\345\276\267\346\243\256/2022_10_26\345\214\205\350\243\205\347\261\273/\346\233\276\345\276\267\346\243\256/\344\275\234\344\270\232/\344\275\234\344\270\232.html" create mode 100644 "47\346\233\276\345\276\267\346\243\256/2022_10_26\345\214\205\350\243\205\347\261\273/\346\233\276\345\276\267\346\243\256/\347\254\224\350\256\260/2022-10-26-\345\214\205\350\243\205\347\261\273.md" diff --git "a/47\346\233\276\345\276\267\346\243\256/2022_10_26\345\214\205\350\243\205\347\261\273/\346\233\276\345\276\267\346\243\256/\344\275\234\344\270\232/\344\275\234\344\270\232.html" "b/47\346\233\276\345\276\267\346\243\256/2022_10_26\345\214\205\350\243\205\347\261\273/\346\233\276\345\276\267\346\243\256/\344\275\234\344\270\232/\344\275\234\344\270\232.html" new file mode 100644 index 0000000..590c1bb --- /dev/null +++ "b/47\346\233\276\345\276\267\346\243\256/2022_10_26\345\214\205\350\243\205\347\261\273/\346\233\276\345\276\267\346\243\256/\344\275\234\344\270\232/\344\275\234\344\270\232.html" @@ -0,0 +1,52 @@ + + + + + + + Document + + + + + \ No newline at end of file diff --git "a/47\346\233\276\345\276\267\346\243\256/2022_10_26\345\214\205\350\243\205\347\261\273/\346\233\276\345\276\267\346\243\256/\347\254\224\350\256\260/2022-10-26-\345\214\205\350\243\205\347\261\273.md" "b/47\346\233\276\345\276\267\346\243\256/2022_10_26\345\214\205\350\243\205\347\261\273/\346\233\276\345\276\267\346\243\256/\347\254\224\350\256\260/2022-10-26-\345\214\205\350\243\205\347\261\273.md" new file mode 100644 index 0000000..9e5397d --- /dev/null +++ "b/47\346\233\276\345\276\267\346\243\256/2022_10_26\345\214\205\350\243\205\347\261\273/\346\233\276\345\276\267\346\243\256/\347\254\224\350\256\260/2022-10-26-\345\214\205\350\243\205\347\261\273.md" @@ -0,0 +1,50 @@ +# 包装类 + +- 原始数据类型: number, boolean, string, null, undefined (symbol,bigint) -> ES6 +- null undefined 没有包装 +- JS 为我们提供了三个包装类,通过这三个包装类可以将**基本数据类型**的数据**转换**为**对象** + - Stiring : 可以基本数据类型字符串转换为String对象 + - Number : 可以基本数据类型数字转换为Number对象 + - Boolean : 可以基本数据类型数字转换为Boolean 对象 + +- **创建基本数据类型的对象** + +```js +var str = new String('hello')  // str是一个值为'hello'的对象 即:String{'hello'} +var str1 = 'hello' +var num = new Number(3)  // num是一个值为3的对象 即:String{'hello'} +var num1 = 3 +var bool = new Boolean(true)  // bool是一个值为true的对象 即:String{'hello'} +var bool2 = true + +console.log(str)  // String {'hello'} +console.log(num)  // Number {3} +console.log(bool)  // Boolean {true} +console.log(typeof str)  // object +console.log(str === str1)  // false  (str是对象,而str1是字符串) +``` + +当我们调用比如字符串的方法时,后台会**临时**通过包装类来创建对象,然后通过对象调用方法,完成之后就会**立即销毁**, + + + + + + + + + + + + + + + + + + + + + + + -- Gitee