ITADN

Optional assignment that creates keys if they dont exist

#6Openlilnasy 创建于 2023-07-17
L
lilnasycommented
I'm curious if the following pattern is something this proposal will consider within scope. ```js // An object containing optimized urls for `imageSrc` in various formats and resolutions const manifest = {} manifest[imageSrc] ??= {} manifest[imageSrc][format] ??= {} manifest[imageSrc][format][width] = url ``` Relevant: lodash's utility: ```js _.setWith(manifest, '[${imageSrc}][${format}][${width}]', url) ```
6 条评论