Function propAccess

  • Returns a property accessor code.

    propAccess('obj', 'foo'); // → obj.foo

    propAccess('obj', 9); // → obj[9]

    propAccess('obj', 'foo bar', true); // → obj?.["foo bar"]

    Parameters

    • code: Code

      The value from which the property is read.

    • name: string | number | Var

      The key of the property.

    • Optional optional: boolean

      If true then optional chaining syntax is used.

    Returns Code

Generated using TypeDoc