Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

253
Views
What do computed and optional mean in a JavaScript MemberExpression AST node?

I have a.x = b.y to be the AST node:

{
  "type": "ExpressionStatement",
  "start": 122,
  "end": 131,
  "expression": {
    "type": "AssignmentExpression",
    "start": 122,
    "end": 131,
    "operator": "=",
    "left": {
      "type": "MemberExpression",
      "start": 122,
      "end": 125,
      "object": {
        "type": "Identifier",
        "start": 122,
        "end": 123,
        "name": "a"
      },
      "property": {
        "type": "Identifier",
        "start": 124,
        "end": 125,
        "name": "x"
      },
      "computed": false,
      "optional": false
    },
    "right": {
      "type": "MemberExpression",
      "start": 128,
      "end": 131,
      "object": {
        "type": "Identifier",
        "start": 128,
        "end": 129,
        "name": "b"
      },
      "property": {
        "type": "Identifier",
        "start": 130,
        "end": 131,
        "name": "y"
      },
      "computed": false,
      "optional": false
    }
  }
}

What does computed and optional mean? What are some examples?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

This is what a.b[c.d[e].f].g looks like:

{
  "type": "Program",
  "body": [
    {
      "type": "MemberExpression",
      "object": {
        "type": "MemberExpression",
        "object": {
          "type": "MemberExpression",
          "object": {
            "type": "Identifier",
            "start": 1,
            "end": 2,
            "name": "a"
          },
          "property": {
            "type": "Identifier",
            "start": 3,
            "end": 4,
            "name": "b"
          },
          "computed": false
        },
        "property": {
          "type": "MemberExpression",
          "object": {
            "type": "MemberExpression",
            "object": {
              "type": "MemberExpression",
              "object": {
                "type": "Identifier",
                "start": 5,
                "end": 6,
                "name": "c"
              },
              "property": {
                "type": "Identifier",
                "start": 7,
                "end": 8,
                "name": "d"
              },
              "computed": false
            },
            "property": {
              "type": "Identifier",
              "start": 9,
              "end": 10,
              "name": "e"
            },
            "computed": true
          },
          "property": {
            "type": "Identifier",
            "start": 12,
            "end": 13,
            "name": "f"
          },
          "computed": false
        },
        "computed": true
      },
      "property": {
        "type": "Identifier",
        "start": 15,
        "end": 16,
        "name": "g"
      },
      "computed": false
    }
  ]
}

The computed is for object[property].

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!