Codiga has joined Datadog!

Read the Blog
Skip to main content

Assignment AST JavaScript Object

The Assignment object matches a JavaScript assignment.

The astType value for this node is assignment.

Code Pattern

This AST element captures the following code.

const myVariable = 1;

Attributes

  • astType: constant string value ("assignment")
  • left (any type that inherits AstElement): the left side of the assignment
  • right (any type that inherits AstElement): the right side of the assignment
info

To know what is the type of left or right, use the astType to distinguish.

For example, to check if the left node is a string, just use the following code:

if (node.left.astType === "string") {
....
}