Struct boa::object::ObjectInitializer [−][src]
pub struct ObjectInitializer<'context> { /* fields omitted */ }Expand description
Builder for creating objects with properties.
Examples
let mut context = Context::new();
let object = ObjectInitializer::new(&mut context)
.property(
"hello",
"world",
Attribute::all()
)
.property(
1,
1,
Attribute::all()
)
.function(|_, _, _| Ok(JsValue::undefined()), "func", 0)
.build();The equivalent in JavaScript would be:
let object = {
hello: "world",
"1": 1,
func: function() {}
}Implementations
pub fn function<B>(
&mut self,
function: NativeFunction,
binding: B,
length: usize
) -> &mut Self where
B: Into<FunctionBinding>,
pub fn function<B>(
&mut self,
function: NativeFunction,
binding: B,
length: usize
) -> &mut Self where
B: Into<FunctionBinding>,
Add a function to the object.
Add a property to the object.