[Javascript] yield*

// Object.prototype[Symbol.iterator] = function() {
//     return Object.values(this)[Symbol.iterator]();
// }

Object.prototype[Symbol.iterator] = function* () {
    // yield* delegates to another generator or iterable object.
    // In this case, it yields each value from the array returned by Object.values(this).
    return yield* Object.values(this);
}

const [a, b] = {a: 1, b: 2}
console.log(a,b)

 

posted @   Zhentiw  阅读(5)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
历史上的今天:
2023-08-26 [Node.js] Create a note cli
2022-08-26 [Web] Preload & Prefetch
2022-08-26 [React] Route-based Splitting
2022-08-26 [React] Import on Visibility
2022-08-26 [React] Compound Pattern
2022-08-26 [React] SWR for data fetching
2022-08-26 [Javascript] Prototype Pattern
点击右上角即可分享
微信分享提示