随笔分类 -  Javascript

上一页 1 2 3 4 5 6 7 8 ··· 30 下一页
摘要:Problem to Solve Share functionality between classes without using inheritance. Solution Create a class containing methods that can be used by other c 阅读全文
posted @ 2024-08-14 14:48 Zhentiw 阅读(4) 评论(0) 推荐(0) 编辑
摘要:class ApplicationError extends Error { get name() { return this.constructor.name; } } class DatabaseError extends ApplicationError {} class UserFacing 阅读全文
posted @ 2024-08-11 22:06 Zhentiw 阅读(2) 评论(0) 推荐(0) 编辑
摘要:class Product { name; price; constructor(name, price) { this.name = name; try { this.price = price * 1.30; } catch(e) { throw new Error("Product canno 阅读全文
posted @ 2024-08-11 22:03 Zhentiw 阅读(2) 评论(0) 推荐(0) 编辑
摘要:Docs: https://webkit.org/blog/6240/ecmascript-6-proper-tail-calls-in-webkit/ /* This is a recursive function without PTC */ function fatorial(n) { if 阅读全文
posted @ 2024-08-07 19:29 Zhentiw 阅读(3) 评论(0) 推荐(0) 编辑
摘要:You don't really need to apply a really complex regex for one validation, instead you can combine multi regex together to fulfilll the task. const reg 阅读全文
posted @ 2024-07-08 14:57 Zhentiw 阅读(5) 评论(0) 推荐(0) 编辑
摘要:Any time when you have non-primitive type, it's going to be removed from memory anytime if it is no longer needed. class Test { constructor(name) { th 阅读全文
posted @ 2024-07-01 19:49 Zhentiw 阅读(5) 评论(0) 推荐(0) 编辑
摘要:function currency(strings, ...values) { return strings.reduce((result, string, i) => { let value = values[i - 1]; if (typeof value "number") { value = 阅读全文
posted @ 2024-06-16 03:23 Zhentiw 阅读(5) 评论(0) 推荐(0) 编辑
摘要:The new cause data property that you can add to a thrown Error can be used to retain access to the original error caught in a promise rejection. const 阅读全文
posted @ 2024-05-22 14:37 Zhentiw 阅读(5) 评论(0) 推荐(0) 编辑
摘要:If we want to be able to modify the state of a promise from outside the constructor, we can use the Promise.withResolvers method to get access to the 阅读全文
posted @ 2024-05-22 14:28 Zhentiw 阅读(13) 评论(0) 推荐(0) 编辑
摘要:The new Array.with method gives you an immutable syntax for changing values of an array at a specified index. Sometimes .map will be more efficient. S 阅读全文
posted @ 2024-05-22 14:22 Zhentiw 阅读(3) 评论(0) 推荐(0) 编辑
摘要:You no longer need to write generator functions to create basic lazy iterator functions. Now, ECMAScript supports iterator helpers that you can call o 阅读全文
posted @ 2024-05-22 02:49 Zhentiw 阅读(6) 评论(0) 推荐(0) 编辑
摘要:The "Set Methods" proposal introduces 7 new methods to JavaScript/ECMAScript: union(setB): Returns a new Set containing all elements from the original 阅读全文
posted @ 2024-05-20 21:59 Zhentiw 阅读(8) 评论(0) 推荐(0) 编辑
摘要:Finding elements starting from the end of an array has gotten a lot easier with the introduction of the at, findLast, and findLastIndex methods! With  阅读全文
posted @ 2024-05-17 14:19 Zhentiw 阅读(9) 评论(0) 推荐(0) 编辑
摘要:Array Grouping is the new feature of JavaScript/ECMAScript, which splits an array (or, generally, an iterable), into smaller sub-arrays. Grouping is d 阅读全文
posted @ 2024-05-17 14:14 Zhentiw 阅读(23) 评论(0) 推荐(0) 编辑
摘要:Intro to Array.prototype.with(index, value) const ages = [10, 15, 20, 25]; const newAges = ages.with(1, 16); console.log(newAges); // [10, 16, 20, 25] 阅读全文
posted @ 2024-03-26 15:28 Zhentiw 阅读(2) 评论(0) 推荐(0) 编辑
摘要:function thankYouTag(arrayOfStrings,firstExpression, secondExpression, ...) { console.log( arrayOfStrings, // ["This is the first one ", " This is ano 阅读全文
posted @ 2024-03-22 02:50 Zhentiw 阅读(1) 评论(0) 推荐(0) 编辑
摘要:Symbol.for("key") Checks if a symbol with the key "key" already exists in the globals symbol registry. If yes, it returns the existing symbol, otherwi 阅读全文
posted @ 2024-03-22 02:39 Zhentiw 阅读(5) 评论(0) 推荐(0) 编辑
摘要:Difference betwen require and import require can be called conditionally, while the import statement cannot import statements are hoisted, but require 阅读全文
posted @ 2024-03-19 15:45 Zhentiw 阅读(3) 评论(0) 推荐(0) 编辑
摘要:Generator can run with for .. of and ..., which will only emit yield values For example: function* count() { yield 1; yield 2; return 3; } for (const 阅读全文
posted @ 2024-03-13 19:42 Zhentiw 阅读(4) 评论(0) 推荐(0) 编辑
摘要:Create a new User instance would create a new login function in memory each time? class User { constructor(username) { this.username = username; } log 阅读全文
posted @ 2024-03-13 19:09 Zhentiw 阅读(5) 评论(0) 推荐(0) 编辑

上一页 1 2 3 4 5 6 7 8 ··· 30 下一页
点击右上角即可分享
微信分享提示