From da91d553deb5e8d6bb69d9a4accf9a3d7c4d292d Mon Sep 17 00:00:00 2001 From: vector090 Date: Thu, 19 Sep 2024 18:58:13 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=BF=BB=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 1-js/05-data-types/03-string/article.md | 2 +- 2-ui/2-events/03-event-delegation/article.md | 2 +- 2-ui/4-forms-controls/2-focus-blur/article.md | 2 +- 2-ui/4-forms-controls/3-events-change-input/article.md | 2 +- 5-network/05-fetch-crossorigin/article.md | 2 +- 5-network/11-websocket/article.md | 4 ++-- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/1-js/05-data-types/03-string/article.md b/1-js/05-data-types/03-string/article.md index 8d381f8e24..ef40df83c6 100644 --- a/1-js/05-data-types/03-string/article.md +++ b/1-js/05-data-types/03-string/article.md @@ -186,7 +186,7 @@ for (let char of "Hello") { let str = 'Hi'; str[0] = 'h'; // error -alert( str[0] ); // 无法运行 +alert( str[0] ); // 没成功 ``` 通常的解决方法是创建一个新的字符串,并将其分配给 `str` 而不是以前的字符串。 diff --git a/2-ui/2-events/03-event-delegation/article.md b/2-ui/2-events/03-event-delegation/article.md index 5c015c8884..5f2e53c189 100644 --- a/2-ui/2-events/03-event-delegation/article.md +++ b/2-ui/2-events/03-event-delegation/article.md @@ -199,7 +199,7 @@ One more counter: ``` -如果我们点击按钮 —— 它的值就会增加。但不仅仅是按钮,一般的方法在这里也很重要。 +如果我们点击按钮 —— 它的值就会增加。这里重要的不是按钮,而是这种通用方法。 我们可以根据需要使用 `data-counter` 特性,多少都可以。我们可以随时向 HTML 添加新的特性。使用事件委托,我们属于对 HTML 进行了“扩展”,添加了描述新行为的特性。 diff --git a/2-ui/4-forms-controls/2-focus-blur/article.md b/2-ui/4-forms-controls/2-focus-blur/article.md index ac3a48062b..fdd5675a41 100644 --- a/2-ui/4-forms-controls/2-focus-blur/article.md +++ b/2-ui/4-forms-controls/2-focus-blur/article.md @@ -90,7 +90,7 @@ Your email please: 请注意,我们无法通过在 `onblur` 事件处理程序中调用 `event.preventDefault()` 来“阻止失去焦点”,因为 `onblur` 事件处理程序是在元素失去焦点 **之后** 运行的。 -但在实际中,在实现这样的功能之前应该认真考虑一下,因为我们通常 **应该将报错展示给用户**,但 **不应该阻止用户在填写我们的表单时的进度**。用户可能会想先填写其他表单项。 +但在实际中,在实现这样的功能之前应该认真考虑一下,因为我们通常 **应该将报错展示给用户**,但 **不应该阻止用户填写表单的进程**。用户可能会想先填写其他表单项。 ```warn header="JavaScript 导致的焦点丢失" 很多种原因可以导致焦点丢失。 diff --git a/2-ui/4-forms-controls/3-events-change-input/article.md b/2-ui/4-forms-controls/3-events-change-input/article.md index 42c0518d26..5c3ece09a1 100644 --- a/2-ui/4-forms-controls/3-events-change-input/article.md +++ b/2-ui/4-forms-controls/3-events-change-input/article.md @@ -95,7 +95,7 @@ 因此,大多数浏览器仅允许在某些用户操作范围内(例如复制/粘贴等)对剪切板进行无缝的读/写访问。 -除火狐(Firefox)浏览器外,所有浏览器都禁止使用 `dispatchEvent` 生成“自定义”剪贴板事件,即使我们设法调度此类事件。规范也明确声明了,合成(syntetic)事件不得提供对剪切板的访问权限。 +除火狐(Firefox)浏览器外,所有浏览器都禁止使用 `dispatchEvent` 生成“自定义”剪贴板事件,即使我们设法调度此类事件。规范也明确声明了,合成(synthetic)事件不得提供对剪切板的访问权限。 此外,如果有人想将 `event.clipboardData` 保存在事件处理程序中,然后稍后再访问它 —— 这也不会生效。 diff --git a/5-network/05-fetch-crossorigin/article.md b/5-network/05-fetch-crossorigin/article.md index d5b662ecc1..252f5a89bd 100644 --- a/5-network/05-fetch-crossorigin/article.md +++ b/5-network/05-fetch-crossorigin/article.md @@ -325,7 +325,7 @@ JavaScript 仅获取对主请求的响应,如果没有服务器许可,则获 这是因为具有凭据的请求比没有凭据的请求要强大得多。如果被允许,它会使用它们的凭据授予 JavaScript 代表用户行为和访问敏感信息的全部权力。 -服务器真的这么信任这种脚本吗?是的,它必须显式地带有允许请求的凭据和附加 header。 +服务器真的这么信任这种脚本吗?如果是的话,它必须显式地带有允许请求的凭据和附加 header。 要在 `fetch` 中发送凭据,我们需要添加 `credentials: "include"` 选项,像这样: diff --git a/5-network/11-websocket/article.md b/5-network/11-websocket/article.md index 51a3f6ec4d..25f249eb91 100644 --- a/5-network/11-websocket/article.md +++ b/5-network/11-websocket/article.md @@ -72,7 +72,7 @@ socket.onerror = function(error) { 当 `new WebSocket(url)` 被创建后,它将立即开始连接。 -在连接期间,浏览器(使用 header)问服务器:“你支持 WebSocket 吗?”如果服务器回复说“我支持”,那么通信就以 WebSocket 协议继续进行,该协议根本不是 HTTP。 +在连接期间,浏览器(使用 header)问服务器:“你支持 WebSocket 吗?”如果服务器回复说“我支持”,那么通信就以 WebSocket 协议继续进行,该协议完全不是 HTTP。 ![](websocket-handshake.svg) @@ -109,7 +109,7 @@ Sec-WebSocket-Accept: hsBlbuDTkk24srzEOTBUlZAlC2g= 这里 `Sec-WebSocket-Accept` 是 `Sec-WebSocket-Key`,是使用特殊的算法重新编码的。浏览器使用它来确保响应与请求相对应。 -然后,使用 WebSocket 协议传输数据,我们很快就会看到它的结构("frames")。它根本不是 HTTP。 +然后,使用 WebSocket 协议传输数据,我们很快就会看到它的结构("frames")。它完全不是 HTTP。 ### 扩展和子协议 From 00a758e919bad28b6d6fc3d19104aa367bac398a Mon Sep 17 00:00:00 2001 From: vector090 Date: Sat, 1 Feb 2025 09:49:18 +0800 Subject: [PATCH 2/3] update --- 1-js/05-data-types/04-array/article.md | 0 1-js/05-data-types/05-array-methods/article.md | 0 1-js/05-data-types/06-iterable/article.md | 0 1-js/05-data-types/07-map-set/article.md | 0 1-js/05-data-types/08-weakmap-weakset/article.md | 0 1-js/05-data-types/12-json/article.md | 0 1-js/06-advanced-functions/04-var/article.md | 0 1-js/06-advanced-functions/06-function-object/article.md | 0 1-js/06-advanced-functions/08-settimeout-setinterval/article.md | 0 1-js/06-advanced-functions/09-call-apply-decorators/article.md | 0 1-js/06-advanced-functions/10-bind/article.md | 0 2-ui/2-events/02-bubbling-and-capturing/both.view/script.js | 2 +- .../02-bubbling-and-capturing/bubble-target.view/script.js | 2 +- 2-ui/2-events/02-bubbling-and-capturing/capture.view/script.js | 2 +- 2-ui/5-loading/01-onload-ondomcontentloaded/article.md | 2 +- 5-network/03-fetch-progress/progress.view/index.html | 2 +- 5-network/11-websocket/article.md | 2 +- 17 files changed, 6 insertions(+), 6 deletions(-) mode change 100644 => 100755 1-js/05-data-types/04-array/article.md mode change 100644 => 100755 1-js/05-data-types/05-array-methods/article.md mode change 100644 => 100755 1-js/05-data-types/06-iterable/article.md mode change 100644 => 100755 1-js/05-data-types/07-map-set/article.md mode change 100644 => 100755 1-js/05-data-types/08-weakmap-weakset/article.md mode change 100644 => 100755 1-js/05-data-types/12-json/article.md mode change 100644 => 100755 1-js/06-advanced-functions/04-var/article.md mode change 100644 => 100755 1-js/06-advanced-functions/06-function-object/article.md mode change 100644 => 100755 1-js/06-advanced-functions/08-settimeout-setinterval/article.md mode change 100644 => 100755 1-js/06-advanced-functions/09-call-apply-decorators/article.md mode change 100644 => 100755 1-js/06-advanced-functions/10-bind/article.md mode change 100644 => 100755 2-ui/2-events/02-bubbling-and-capturing/both.view/script.js mode change 100644 => 100755 2-ui/2-events/02-bubbling-and-capturing/bubble-target.view/script.js mode change 100644 => 100755 2-ui/2-events/02-bubbling-and-capturing/capture.view/script.js diff --git a/1-js/05-data-types/04-array/article.md b/1-js/05-data-types/04-array/article.md old mode 100644 new mode 100755 diff --git a/1-js/05-data-types/05-array-methods/article.md b/1-js/05-data-types/05-array-methods/article.md old mode 100644 new mode 100755 diff --git a/1-js/05-data-types/06-iterable/article.md b/1-js/05-data-types/06-iterable/article.md old mode 100644 new mode 100755 diff --git a/1-js/05-data-types/07-map-set/article.md b/1-js/05-data-types/07-map-set/article.md old mode 100644 new mode 100755 diff --git a/1-js/05-data-types/08-weakmap-weakset/article.md b/1-js/05-data-types/08-weakmap-weakset/article.md old mode 100644 new mode 100755 diff --git a/1-js/05-data-types/12-json/article.md b/1-js/05-data-types/12-json/article.md old mode 100644 new mode 100755 diff --git a/1-js/06-advanced-functions/04-var/article.md b/1-js/06-advanced-functions/04-var/article.md old mode 100644 new mode 100755 diff --git a/1-js/06-advanced-functions/06-function-object/article.md b/1-js/06-advanced-functions/06-function-object/article.md old mode 100644 new mode 100755 diff --git a/1-js/06-advanced-functions/08-settimeout-setinterval/article.md b/1-js/06-advanced-functions/08-settimeout-setinterval/article.md old mode 100644 new mode 100755 diff --git a/1-js/06-advanced-functions/09-call-apply-decorators/article.md b/1-js/06-advanced-functions/09-call-apply-decorators/article.md old mode 100644 new mode 100755 diff --git a/1-js/06-advanced-functions/10-bind/article.md b/1-js/06-advanced-functions/10-bind/article.md old mode 100644 new mode 100755 diff --git a/2-ui/2-events/02-bubbling-and-capturing/both.view/script.js b/2-ui/2-events/02-bubbling-and-capturing/both.view/script.js old mode 100644 new mode 100755 index c3475f5cbb..79195638d7 --- a/2-ui/2-events/02-bubbling-and-capturing/both.view/script.js +++ b/2-ui/2-events/02-bubbling-and-capturing/both.view/script.js @@ -7,6 +7,6 @@ for (let i = 0; i < elems.length; i++) { function highlightThis() { this.style.backgroundColor = 'yellow'; - alert(this.tagName); + console.log(this.tagName); this.style.backgroundColor = ''; } \ No newline at end of file diff --git a/2-ui/2-events/02-bubbling-and-capturing/bubble-target.view/script.js b/2-ui/2-events/02-bubbling-and-capturing/bubble-target.view/script.js old mode 100644 new mode 100755 index b1353712fa..24f586d594 --- a/2-ui/2-events/02-bubbling-and-capturing/bubble-target.view/script.js +++ b/2-ui/2-events/02-bubbling-and-capturing/bubble-target.view/script.js @@ -4,7 +4,7 @@ form.onclick = function(event) { // chrome needs some time to paint yellow setTimeout(() => { - alert("target = " + event.target.tagName + ", this=" + this.tagName); + console.log("target = " + event.target.tagName + ", this=" + this.tagName); event.target.style.backgroundColor = '' }, 0); }; diff --git a/2-ui/2-events/02-bubbling-and-capturing/capture.view/script.js b/2-ui/2-events/02-bubbling-and-capturing/capture.view/script.js old mode 100644 new mode 100755 index d67a496ad7..a82d2b8796 --- a/2-ui/2-events/02-bubbling-and-capturing/capture.view/script.js +++ b/2-ui/2-events/02-bubbling-and-capturing/capture.view/script.js @@ -6,6 +6,6 @@ for (let i = 0; i < elems.length; i++) { function highlightThis() { this.style.backgroundColor = 'yellow'; - alert(this.tagName); + console.log(this.tagName); this.style.backgroundColor = ''; } \ No newline at end of file diff --git a/2-ui/5-loading/01-onload-ondomcontentloaded/article.md b/2-ui/5-loading/01-onload-ondomcontentloaded/article.md index 7e74ce690f..c4d77ced3f 100644 --- a/2-ui/5-loading/01-onload-ondomcontentloaded/article.md +++ b/2-ui/5-loading/01-onload-ondomcontentloaded/article.md @@ -101,7 +101,7 @@ document.addEventListener("DOMContentLoaded", ready); Firefox,Chrome 和 Opera 都会在 `DOMContentLoaded` 中自动填充表单。 -例如,如果页面有一个带有登录名和密码的表单,并且浏览器记住了这些值,那么在 `DOMContentLoaded` 上,浏览器会尝试自动填充它们(如果得到了用户允许)。 +例如,如果页面有一个带有登录名和密码的表单,并且浏览器记住了这些值,那么当 `DOMContentLoaded` 时,浏览器会尝试自动填充它们(如果得到了用户允许)。 因此,如果 `DOMContentLoaded` 被需要加载很长时间的脚本延迟触发,那么自动填充也会等待。你可能在某些网站上看到过(如果你使用浏览器自动填充)—— 登录名/密码字段不会立即自动填充,而是在页面被完全加载前会延迟填充。这实际上是 `DOMContentLoaded` 事件之前的延迟。 diff --git a/5-network/03-fetch-progress/progress.view/index.html b/5-network/03-fetch-progress/progress.view/index.html index ba7f76065e..0da4c184c8 100644 --- a/5-network/03-fetch-progress/progress.view/index.html +++ b/5-network/03-fetch-progress/progress.view/index.html @@ -1,6 +1,6 @@ + + + + diff --git a/2-ui/1-document/08-styles-and-classes/1.html b/2-ui/1-document/08-styles-and-classes/1.html new file mode 100755 index 0000000000..4ebfa3d2a8 --- /dev/null +++ b/2-ui/1-document/08-styles-and-classes/1.html @@ -0,0 +1,16 @@ + + + + diff --git a/2-ui/2-events/01-introduction-browser-events/1.html b/2-ui/2-events/01-introduction-browser-events/1.html new file mode 100755 index 0000000000..14e9ef8949 --- /dev/null +++ b/2-ui/2-events/01-introduction-browser-events/1.html @@ -0,0 +1,3 @@ + + + diff --git a/2-ui/2-events/01-introduction-browser-events/2.html b/2-ui/2-events/01-introduction-browser-events/2.html new file mode 100755 index 0000000000..af63180e31 --- /dev/null +++ b/2-ui/2-events/01-introduction-browser-events/2.html @@ -0,0 +1,7 @@ + + \ No newline at end of file diff --git a/2-ui/2-events/01-introduction-browser-events/3.html b/2-ui/2-events/01-introduction-browser-events/3.html new file mode 100755 index 0000000000..61f0023e54 --- /dev/null +++ b/2-ui/2-events/01-introduction-browser-events/3.html @@ -0,0 +1,3 @@ + + + diff --git a/2-ui/2-events/03-event-delegation/counter.html b/2-ui/2-events/03-event-delegation/counter.html new file mode 100755 index 0000000000..ae37b6b884 --- /dev/null +++ b/2-ui/2-events/03-event-delegation/counter.html @@ -0,0 +1,15 @@ + +Counter: +One more counter: + + diff --git a/2-ui/2-events/03-event-delegation/menu.html b/2-ui/2-events/03-event-delegation/menu.html new file mode 100755 index 0000000000..875b8c4256 --- /dev/null +++ b/2-ui/2-events/03-event-delegation/menu.html @@ -0,0 +1,39 @@ + + + + diff --git a/4-binary/01-arraybuffer-binary-arrays/1.js b/4-binary/01-arraybuffer-binary-arrays/1.js new file mode 100755 index 0000000000..b26902a5a7 --- /dev/null +++ b/4-binary/01-arraybuffer-binary-arrays/1.js @@ -0,0 +1,20 @@ + +let buffer = new ArrayBuffer(16); // 创建一个长度为 16 的 buffer + +let view = new Uint32Array(buffer); // 将 buffer 视为一个 32 位整数的序列 + +console.log(Uint32Array.BYTES_PER_ELEMENT); // 每个整数 4 个字节 + +console.log(view.length); // 4,它存储了 4 个整数 +console.log(view.byteLength); // 16,字节中的大小 + +// 让我们写入一个值 +view[0] = 123456; + +// 遍历值 +for(let num of view) { + console.log(num); // 123456,然后 0,0,0(一共 4 个值) +} + +console.log(view); +// Uint32Array(4) [ 123456, 0, 0, 0 ] diff --git a/4-binary/01-arraybuffer-binary-arrays/2.js b/4-binary/01-arraybuffer-binary-arrays/2.js new file mode 100755 index 0000000000..773ec6cd53 --- /dev/null +++ b/4-binary/01-arraybuffer-binary-arrays/2.js @@ -0,0 +1,8 @@ + +let arr16 = new Uint16Array([1, 1000]); +let arr8 = new Uint8Array(arr16); +console.log( arr8[0] ); // 1 +console.log( arr8[1] ); // 232,试图复制 1000,但无法将 1000 放进 8 位字节中(详述见下文)。 + +console.log( arr8[2] ); +// undefined diff --git a/4-binary/01-arraybuffer-binary-arrays/3.js b/4-binary/01-arraybuffer-binary-arrays/3.js new file mode 100755 index 0000000000..17c6ba76d8 --- /dev/null +++ b/4-binary/01-arraybuffer-binary-arrays/3.js @@ -0,0 +1,11 @@ + +let uint7array = new Uint8Array(16); + +let num = 255; +console.log(num.toString(2)); // 100000000(二进制表示) + +uint7array[0] = 256; +uint7array[1] = 257; + +console.log(uint7array[0]); // 0 +console.log(uint7array[1]); // 1 diff --git a/4-binary/01-arraybuffer-binary-arrays/4.js b/4-binary/01-arraybuffer-binary-arrays/4.js new file mode 100755 index 0000000000..32e219cb7e --- /dev/null +++ b/4-binary/01-arraybuffer-binary-arrays/4.js @@ -0,0 +1,24 @@ + +// 4 个字节的二进制数组,每个都是最大值 255 +let buffer = new Uint8Array([255, 255, 255, 255]).buffer; + +let dataView = new DataView(buffer); + +// 在偏移量为 0 处获取 8 位数字 +console.log( dataView.getUint8(0) ); // 255 + +console.log( dataView.getUint8(1) ); // 255 +console.log( dataView.getUint8(3) ); // 255 + +// console.log( dataView.getUint8(4) ); +// RangeError: Offset is outside the bounds of the DataView + + + +// 现在在偏移量为 0 处获取 16 位数字,它由 2 个字节组成,一起解析为 65535 +console.log( dataView.getUint16(0) ); // 65535(最大的 16 位无符号整数) + +// 在偏移量为 0 处获取 32 位数字 +console.log( dataView.getUint32(0) ); // 4294967295(最大的 32 位无符号整数) + +dataView.setUint32(0, 0); // 将 4 个字节的数字设为 0,即将所有字节都设为 0 diff --git a/4-binary/01-arraybuffer-binary-arrays/8.js b/4-binary/01-arraybuffer-binary-arrays/8.js new file mode 100755 index 0000000000..138920d825 --- /dev/null +++ b/4-binary/01-arraybuffer-binary-arrays/8.js @@ -0,0 +1,4 @@ + +let arr = new Uint8Array([0, 1, 2, 3]); +console.log( arr.length ); // 4,创建了相同长度的二进制数组 +console.log( arr[1] ); // 1,用给定值填充了 4 个字节(无符号 8 位整数) diff --git a/4-binary/03-blob/1.html b/4-binary/03-blob/1.html new file mode 100755 index 0000000000..9344f17574 --- /dev/null +++ b/4-binary/03-blob/1.html @@ -0,0 +1,14 @@ + + +Download + + diff --git a/4-binary/03-blob/2.html b/4-binary/03-blob/2.html new file mode 100755 index 0000000000..fe4e6f450d --- /dev/null +++ b/4-binary/03-blob/2.html @@ -0,0 +1,3 @@ + + + diff --git a/4-binary/03-blob/3.html b/4-binary/03-blob/3.html new file mode 100755 index 0000000000..685a932660 --- /dev/null +++ b/4-binary/03-blob/3.html @@ -0,0 +1,17 @@ + + diff --git a/4-binary/03-blob/4.html b/4-binary/03-blob/4.html new file mode 100755 index 0000000000..768c9bc088 --- /dev/null +++ b/4-binary/03-blob/4.html @@ -0,0 +1,44 @@ + + + + + + + + diff --git a/4-binary/04-file/1.html b/4-binary/04-file/1.html new file mode 100755 index 0000000000..2822e7cf9f --- /dev/null +++ b/4-binary/04-file/1.html @@ -0,0 +1,26 @@ + + + + diff --git a/5-network/01-fetch/1.js b/5-network/01-fetch/1.js new file mode 100755 index 0000000000..52c2883086 --- /dev/null +++ b/5-network/01-fetch/1.js @@ -0,0 +1,11 @@ + +( async function(){ + +let url = 'https://api.github.com/repos/javascript-tutorial/en.javascript.info/commits'; +let response = await fetch(url); + +let commits = await response.json(); // 读取 response body,并将其解析为 JSON 格式 + +console.log(commits[0].author.login); + +} )(); diff --git a/5-network/01-fetch/2.js b/5-network/01-fetch/2.js new file mode 100755 index 0000000000..242c98c6de --- /dev/null +++ b/5-network/01-fetch/2.js @@ -0,0 +1,4 @@ + +fetch('https://api.github.com/repos/javascript-tutorial/en.javascript.info/commits') + .then(response => response.json()) + .then(commits => console.log(commits[0].author.login)); diff --git a/5-network/01-fetch/3.js b/5-network/01-fetch/3.js new file mode 100755 index 0000000000..0230822102 --- /dev/null +++ b/5-network/01-fetch/3.js @@ -0,0 +1,15 @@ + + +( async function(){ + +let response = await fetch('https://api.github.com/repos/javascript-tutorial/en.javascript.info/commits'); + +// 获取一个 header +console.log(response.headers.get('Content-Type')); // application/json; charset=utf-8 + +// 迭代所有 header +for (let [key, value] of response.headers) { + console.log(`${key} = ${value}`); +} + +} )(); \ No newline at end of file diff --git a/5-network/01-fetch/4.js b/5-network/01-fetch/4.js new file mode 100755 index 0000000000..ff03a7ffa6 --- /dev/null +++ b/5-network/01-fetch/4.js @@ -0,0 +1,14 @@ + +// must await, otherwise won't get result + +// ERR + +let response = fetch('https://api.github.com/repos/javascript-tutorial/en.javascript.info/commits'); + +// 获取一个 header +console.log(response.headers.get('Content-Type')); // application/json; charset=utf-8 + +// 迭代所有 header +for (let [key, value] of response.headers) { + console.log(`${key} = ${value}`); +} diff --git a/5-network/01-fetch/post.js b/5-network/01-fetch/post.js new file mode 100755 index 0000000000..86a2dcaf78 --- /dev/null +++ b/5-network/01-fetch/post.js @@ -0,0 +1,21 @@ + +( async function(){ + +let user = { + name: 'John', + surname: 'Smith' + }; + + let response = await fetch('https://zh.javascript.info/article/fetch/post/user', { + method: 'POST', + headers: { + 'Content-Type': 'application/json;charset=utf-8' + }, + body: JSON.stringify(user) + }); + + let result = await response.json(); + console.log(result.message); + console.dir(result); + +} )(); \ No newline at end of file diff --git a/5-network/08-xmlhttprequest/1.html b/5-network/08-xmlhttprequest/1.html new file mode 100755 index 0000000000..a63b4112ff --- /dev/null +++ b/5-network/08-xmlhttprequest/1.html @@ -0,0 +1,35 @@ + + diff --git a/js-notes-me.md b/js-notes-me.md new file mode 100755 index 0000000000..a02a4cb5dd --- /dev/null +++ b/js-notes-me.md @@ -0,0 +1,41 @@ + +# 关于 prototype 原型 + +取 对象的原型: __proto__ (~=父类) +(如果取对象的 prototype,会得到 null) + + 原理是 __proto__ 是在 Object.prototype 中定义的 setter/getter 函数 + + +取 函数的原型: prototype (到具体的父类(父函数)) +如果取某函数的 __proto__ (父类),会拿到 Function.prototype (合理) + + +取 (class)的原型: prototype + 例如 Array.prototype + + +extends 只能从一个父类继承, +如果想有多个父类的能力,用 mixin + + +# proxy +类似 java 里的 proxy +也有点像 C++ 里的操作符重载 + + +# curry 化 +有点像偏导数 + + +html element -> attribute +DOM -> property + + +某个element.append/prepend, before/after, replaceWith 这些都是以纯文本形式插入,不会识别为 html +要想插入 html 的话,用 elm.insertAdjacentHTML/Text/Element + + +想读尺寸数值的话,不要读 css,而是那些几何属性 clientXXX, xxxHeight 等 + +