pub enum PropertyDefinition {
IdentifierReference(Box<str>),
Property(PropertyName, Node),
MethodDefinition(MethodDefinitionKind, PropertyName, FunctionExpr),
SpreadObject(Node),
}
Expand description
A JavaScript property is a characteristic of an object, often describing attributes associated with a data structure.
A property has a name (a string) and a value (primitive, method, or object reference). Note that when we say that “a property holds an object”, that is shorthand for “a property holds an object reference”. This distinction matters because the original referenced object remains unchanged when you change the property’s value.
More information:
Variants§
IdentifierReference(Box<str>)
Property(PropertyName, Node)
Binds a property name to a JavaScript value.
More information:
MethodDefinition(MethodDefinitionKind, PropertyName, FunctionExpr)
A property of an object can also refer to a function or a getter or setter method.
More information:
SpreadObject(Node)
The Rest/Spread Properties for ECMAScript proposal (stage 4) adds spread properties to object literals. It copies own enumerable properties from a provided object onto a new object.
Shallow-cloning (excluding prototype
) or merging objects is now possible using a shorter syntax than Object.assign()
.
More information:
Implementations§
Source§impl PropertyDefinition
impl PropertyDefinition
Sourcepub fn identifier_reference<I>(ident: I) -> Self
pub fn identifier_reference<I>(ident: I) -> Self
Creates an IdentifierReference
property definition.
Sourcepub fn method_definition<N>(
kind: MethodDefinitionKind,
name: N,
body: FunctionExpr,
) -> Selfwhere
N: Into<PropertyName>,
pub fn method_definition<N>(
kind: MethodDefinitionKind,
name: N,
body: FunctionExpr,
) -> Selfwhere
N: Into<PropertyName>,
Creates a MethodDefinition
.
Sourcepub fn spread_object<O>(obj: O) -> Self
pub fn spread_object<O>(obj: O) -> Self
Creates a SpreadObject
.
Trait Implementations§
Source§impl Clone for PropertyDefinition
impl Clone for PropertyDefinition
Source§fn clone(&self) -> PropertyDefinition
fn clone(&self) -> PropertyDefinition
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more