[英]Destructuring an object with “delete” as property
In Javascript, is it possible to destructure an object with "delete" as one of its properties? 在Javascript中,是否可以使用“删除”作为其属性之一来破坏对象?
class MyClass {
constructor ( { prop1, prop2, delete, prop4 } ) {
this.prop1 = prop1
this.prop2 = prop2
this.delete = delete
this.prop4 = prop4
}
}
delete
is a reserved keyword, you cannot have that as a variable name . delete
是保留关键字,不能将其用作变量名 。 Therefore you have to rename it during destructuring: 因此,您必须在解构期间重命名它:
{ delete: otherName }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.