Object Property Shorthand
Description
In OSL, you can use the object property shorthand to create objects more concisely. When the property name and the variable name are the same, you can omit the value in the object literal.
Usage
In the provided example, the variable var
is defined with the value "hello world"
. The log
method is then used to output an object containing var
and var2
. The shorthand syntax allows you to include var
in the object without explicitly specifying its value.
A variable
var
is defined with the value"hello world"
.The
log
method is called with an object containingvar
andvar2
.The output is an object with the values of
var
andvar2
.
Last updated
Was this helpful?