上一页 1 2 3 4 5 6 7 8 9 ··· 25 下一页
摘要: Promise.resolve(promise对象) 的作用其实非常直白:它会原封不动地返回这个 Promise 对象。 也就是说,如果你把一个已经存在的 Promise 传进去,Promise.resolve() 不会创建新的 Promise,也不会改变它的状态,而是直接把这个“原对象”吐出来。 阅读全文
posted @ 2026-03-28 14:12 chenlight 阅读(14) 评论(0) 推荐(0)
摘要: 在这篇文章中,我将阐述 ES2017 的异步函数(async functions)本质上是如何在两个较旧的 JavaScript 特性之间“博弈”的:即生成器(generators)和 Promise。原文称这两者都是在 ES2016 规范中更早加入该语言的。 开始阅读之前 .. 本文并非关于 Pr 阅读全文
posted @ 2026-03-28 14:05 chenlight 阅读(9) 评论(0) 推荐(0)
摘要: 第一步还是先来看下具体的代码,如下: function *test(){ let value1 = yield 1; console.log(value1); let value2 = yield 2; console.log(value2); } var iter = test(); consol 阅读全文
posted @ 2026-03-25 20:49 chenlight 阅读(9) 评论(0) 推荐(0)
摘要: 在 JavaScript 中,Map 是 ES6(ECMAScript 2015)引入的一种全新的数据结构,用于存储键值对(key-value pairs)。 专门用来解决传统对象({})无法用非字符串 / 非 Symbol 类型作为键、键会被隐式转换、无法获取键值对数量等痛点。 一、为什么需要 M 阅读全文
posted @ 2026-03-24 21:02 chenlight 阅读(19) 评论(0) 推荐(0)
摘要: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <!-- 引入 jQuery(建议使用CDN或本地文件) --> <script src="https://code.jquery. 阅读全文
posted @ 2026-03-23 16:32 chenlight 阅读(9) 评论(0) 推荐(0)
摘要: 先看代码,如下所示: var x = 0; function foo(x, y = function() { x = 3; console.log(x); }) { console.log('the first is:',x); var x = 2; y(); console.log('the se 阅读全文
posted @ 2026-03-23 10:48 chenlight 阅读(8) 评论(0) 推荐(0)
摘要: python中,相应的RSA加密代码如下: 首先的前提还是要安装好pycryptodome库 from Crypto.PublicKey import RSA from Crypto.Cipher import PKCS1_v1_5 import base64 def pkcs1_v1_5(publ 阅读全文
posted @ 2026-03-20 20:59 chenlight 阅读(22) 评论(0) 推荐(0)
摘要: from Crypto.PublicKey import RSA # 1. 生成 RSA 密钥对 (2048位) rsa_key = RSA.generate(2048) # 导出公钥 public_key = rsa_key.publickey().exportKey() print(public 阅读全文
posted @ 2026-03-20 14:51 chenlight 阅读(20) 评论(0) 推荐(0)
摘要: 在 Python 中,-> 符号是函数注解(Function Annotations)的一部分,专门用于提示函数的返回值类型。它只是一种 “提示”,Python 解释器不会强制检查类型是否匹配(需要借助 mypy 等工具才能做类型校验),但能极大提升代码的可读性和可维护性。 基础示例 先看一个最简单 阅读全文
posted @ 2026-03-19 17:12 chenlight 阅读(44) 评论(0) 推荐(0)
摘要: 随着ES6的引入,迭代器和生成器已经正式添加到JavaScript中。 迭代器能让你遍历任何符合规范的对象。在文章的第一部分,我们会探讨如何使用迭代器,以及如何让任意对象变得可迭代。 这篇博客的第二部分将完全聚焦于生成器(Generators):它们是什么、如何使用,以及在哪些场景下能派上用场。 我 阅读全文
posted @ 2026-03-11 19:42 chenlight 阅读(10) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 7 8 9 ··· 25 下一页