scitools.com

← Metric catalog

Executable Statements (JavaScript) is one of the source-code metrics Understand computes across 17+ languages — browse them in the GUI, export and track them, or script them with the Python API.

Executable Statements (JavaScript)

API IDCountStmtExeJavascript
TargetsArchitectures Files Project
LanguagesWeb
CategoriesStatements
CostLookup
TagsWeb Breakdown

Number of JavaScript executable statements.

For example:

<!DOCTYPE html>
<html>
<head>
  <title>Welcome</title>

  <!-- Greeting script: tracks visits and confirms with the user -->
  <script>
    // Number of times the page has greeted someone
    var greetingCount = 0;

    function greetUser(name) {
      greetingCount++;
      return "Hello, " + name + "!";
    }

    let message = greetUser("Ada");
    console.log(message);

    if (greetingCount > 0) {
      confirm(message);
    }
  </script>
</head>
<body>
  <h1>Welcome to the site</h1>
  <p>Have a look around.</p>
</body>
</html>

greetingCount++; (12), the return statement (13), let message = greetUser("Ada"); (16, which also declares message), console.log(message); (17), the if statement (19), and confirm(message); (20) are executable, giving CountStmtExeJavascript = 6.

See Declarative Statements (JavaScript) for the complementary breakdown, and Executable Statements for the combined count across all languages.

Targets By Language: