带三个点的Javascript属性(...) [英] Javascript Property with three dots (...)

查看:60
本文介绍了带三个点的Javascript属性(...)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我应该使用的代码有问题.我找到了一个我不熟悉的语法,并且在查阅文档时遇到了麻烦:

I have a problem with code I am supposed to work with. I found a syntax I am not familiar with and I have trouble googling the documentation:

export const Something = class Something {
    constructor(someObject = {}) {
        this.someObject = {...Something.someObjectDefaultAsStaticMethod,...someThing};
    };
// The rest of the class
};

我很难理解参数前面的三个点(...)的作用.而且参数javascript中的点"是一个错误的搜索词.有人可以帮我,也许告诉我实际上该语法是什么,还是直接将我链接到文档?

I have problems understanding what the three dots (...) in front of the parameter do. And "dots in parameter javascript" is a bad search term. Can someone help me, maybe tell me what this syntax is actually called or just directly link me to documentation?

推荐答案

不是ES6,仅在ECMAScript 2018中添加.

That is not ES6 but has only been added in ECMAScript 2018.

它称为对象剩余/扩展属性",是传播语法.

It is called "Object Rest/Spread Properties" and is part of the Spread Syntax.

这篇关于带三个点的Javascript属性(...)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆