scitools.com

← Metric catalog

Code Lines (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.

Code Lines (JavaScript)

API IDCountLineCodeJavascript
TargetsArchitectures Files Project
LanguagesWeb
CategoriesLines
CostLookup
TagsWeb Breakdown

Number of JavaScript lines containing source code.

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>

Of the 14 JavaScript lines, 10 contain code — every line except the comment (8) and the three blank lines (10, 15, 18) — giving CountLineCodeJavascript = 10.

See Code Lines for the combined count across all languages, and Code Lines (PHP) for the PHP equivalent.

Targets By Language: