Skip to content

JavaScript

Last verified end to end: 2026-07-14 (query_code schema version 2).

For exact inbound and outbound symbol edges, proof tiers, and adapter-specific caveats, see Reference Traversal.

JavaScript normalizes functions, methods, constructors, arrows, class declarations and expressions, calls and new, imports, assignments, and member access. It does not invent keyword arguments for a language that has none.

import service from "./service.js";
function audit(value) {
return value;
}
class Runner {
constructor(client) {
this.client = client;
}
run(payload) {
backup.send(payload);
service.send(payload);
return audit(payload);
}
}
const factory = () => new Runner(service);
const Inline = class {
save(value) {
return service.send(value);
}
};

The fixture contains three send calls. Receiver and enclosing-method filters select only service.send(payload) in Runner.run.

(inside
(method :name "run")
(language javascript
(call :callee "send" :receiver "service" :args [(capture "payload")])))
{
"languages": ["javascript"],
"match": {
"kind": "call",
"callee": {"name": "send"},
"receiver": {"name": "service"},
"args": [{"capture": "payload"}]
},
"inside": {"kind": "method", "name": "run"}
}
{
"results": [
{
"result_type": "structural_match",
"path": "javascript/app.js",
"language": "javascript",
"kind": "call",
"start_line": 14,
"end_line": 14,
"text": "service.send(payload)",
"captures": [
{"name": "payload", "text": "payload", "start_line": 14}
],
"enclosing_symbol": "Runner.run"
}
],
"truncated": false
}

new Runner(...) is a normalized call, so an arrow can be selected by a descendant call whose callee is Runner.

(lambda :capture "factory" (has (call :callee "Runner")))
{
"match": {
"kind": "lambda",
"capture": "factory",
"has": {"kind": "call", "callee": {"name": "Runner"}}
}
}
{
"results": [
{
"result_type": "structural_match",
"path": "javascript/app.js",
"language": "javascript",
"kind": "lambda",
"start_line": 19,
"end_line": 19,
"text": "() => new Runner(service)",
"captures": [
{
"name": "factory",
"text": "() => new Runner(service)",
"start_line": 19
}
],
"enclosing_symbol": "factory"
}
],
"truncated": false
}

Anonymous class expressions are queryable as class, but the assignment binding is not their normalized class name. A text regex selects the anonymous class { shape, while the descendant field access is constrained through normalized object and field roles.

(class
(text/regex "^class \\{")
(has (field_access :object "service" :field "send")))
{
"match": {
"kind": "class",
"text": {"regex": "^class \\{"},
"has": {
"kind": "field_access",
"object": {"name": "service"},
"field": {"name": "send"}
}
}
}
{
"results": [
{
"result_type": "structural_match",
"path": "javascript/app.js",
"language": "javascript",
"kind": "class",
"start_line": 20,
"end_line": 24,
"text": "class {…",
"enclosing_symbol": "app.js.Inline"
}
],
"truncated": false
}
(language javascript (call :callee "send" :kwargs [(value (capture "value"))]))
{
"languages": ["javascript"],
"match": {
"kind": "call",
"callee": {"name": "send"},
"kwargs": {"value": {"capture": "value"}}
}
}
{
"results": [],
"truncated": false,
"diagnostics": [
{
"language": "javascript",
"message": "structural adapter for javascript does not support role(s): kwargs"
}
]
}

service is matched as source structure, not resolved to the imported binding. Follow a structural result with symbol/usage tools when identity matters.

class QueryRoot {
rootMember() {}
}
class QueryLeaf extends QueryRoot {
leafMember() {}
}
(supertypes (enclosing-decl (language javascript (class :name "QueryLeaf"))))
{"languages":["javascript"],"match":{"kind":"class","name":"QueryLeaf"},"steps":[{"op":"enclosing_decl"},{"op":"supertypes"}]}
{
"results": [
{
"end_line": 3,
"fq_name": "QueryRoot",
"kind": "class",
"language": "javascript",
"path": "javascript/hierarchy.js",
"provenance": [
{
"seed": {
"end_line": 7,
"kind": "class",
"path": "javascript/hierarchy.js",
"result_type": "structural_match",
"start_line": 5
},
"steps": [
{
"op": "enclosing_decl",
"result": {
"end_line": 7,
"fq_name": "QueryLeaf",
"kind": "class",
"path": "javascript/hierarchy.js",
"result_type": "declaration",
"start_line": 5
}
},
{
"op": "supertypes",
"result": {
"end_line": 3,
"fq_name": "QueryRoot",
"kind": "class",
"path": "javascript/hierarchy.js",
"result_type": "declaration",
"start_line": 1
}
}
]
}
],
"result_type": "declaration",
"signature": "class QueryRoot {",
"start_line": 1
}
],
"truncated": false
}
(owner (members (subtypes :depth 2 (enclosing-decl (language javascript (class :name "QueryRoot"))))))
{"languages":["javascript"],"match":{"kind":"class","name":"QueryRoot"},"steps":[{"op":"enclosing_decl"},{"op":"subtypes","depth":2},{"op":"members"},{"op":"owner"}]}
{
"results": [
{
"end_line": 7,
"fq_name": "QueryLeaf",
"kind": "class",
"language": "javascript",
"path": "javascript/hierarchy.js",
"provenance": [
{
"seed": {
"end_line": 3,
"kind": "class",
"path": "javascript/hierarchy.js",
"result_type": "structural_match",
"start_line": 1
},
"steps": [
{
"op": "enclosing_decl",
"result": {
"end_line": 3,
"fq_name": "QueryRoot",
"kind": "class",
"path": "javascript/hierarchy.js",
"result_type": "declaration",
"start_line": 1
}
},
{
"op": "subtypes",
"result": {
"end_line": 7,
"fq_name": "QueryLeaf",
"kind": "class",
"path": "javascript/hierarchy.js",
"result_type": "declaration",
"start_line": 5
}
},
{
"op": "members",
"result": {
"end_line": 6,
"fq_name": "QueryLeaf.leafMember",
"kind": "function",
"path": "javascript/hierarchy.js",
"result_type": "declaration",
"start_line": 6
}
},
{
"op": "owner",
"result": {
"end_line": 7,
"fq_name": "QueryLeaf",
"kind": "class",
"path": "javascript/hierarchy.js",
"result_type": "declaration",
"start_line": 5
}
}
]
}
],
"result_type": "declaration",
"signature": "class QueryLeaf extends QueryRoot {",
"start_line": 5
}
],
"truncated": false
}