JavaScript (Node.js)

Terminal Guide & Documentation

JavaScript (Node.js)

1. Introduction & Use Cases

JavaScript is no longer just for browsers. With Node.js in Termux, you can build powerful server-side applications, automation scripts, and even sophisticated hacking tools directly on your mobile device.

  • Backend Development: Creating REST APIs and web servers using Express.js.
  • Tooling: Writing CLI tools and automation scripts.
  • Networking: Building real-time applications with WebSockets.
  • Security: Analyzing web traffic and creating security scanners.

2. Basic Syntax & Variables

JavaScript uses modern ES6+ syntax. To install Node.js in Termux, use pkg install nodejs.

bash — basics.js
// Modern variable declarations
const platform = "Termux";
let status = "learning";
const isAwesome = true;

console.log(`System: ${platform}`);
console.log(`Current Status: ${status}`);

3. Control Flow & Functions

Functional programming and logical control in JavaScript.

bash — functions.js
// Arrow function example
const greetUser = (name) => {
    return `Welcome back, ${name}!`;
};

const users = ["Alice", "Bob", "Charlie"];
users.forEach(user => {
    console.log(greetUser(user));
});

4. Core Commands Cheat-sheet

  • node script.js - Run a JavaScript file.
  • npm init - Initialize a new project.
  • npm install [package] - Install a module.
  • process.platform - Identify the OS platform.
  • fs.readFileSync() - Read files from the system.

5. Popular Libraries & Frameworks

  • Express.js: The most popular web framework for Node.js.
  • Axios: Promise-based HTTP client for the browser and node.js.
  • Puppeteer: Headless Chrome Node.js API for web scraping.
  • Socket.io: Real-time bidirectional event-based communication.
  • Lodash: A modern JavaScript utility library.

6. Advanced Practical Example: Calculator

A simple command-line calculator that takes arguments from the terminal.

bash — calculator.js
// Simple CLI Calculator
const args = process.argv.slice(2);
const num1 = parseFloat(args[0]);
const operator = args[1];
const num2 = parseFloat(args[2]);

const calculate = (a, op, b) => {
    switch(op) {
        case '+': return a + b;
        case '-': return a - b;
        case '*': return a * b;
        case '/': return a / b;
        default: return "Invalid Operator";
    }
};

if (args.length === 3) {
    console.log(`Result: ${calculate(num1, operator, num2)}`);
} else {
    console.log("Usage: node calculator.js 5 + 10");
}

Explore More Tools

Python

Master automation and security scripting.

C++

Develop high-performance system tools.

Apache

Host local websites in Termux.

Explore Termux Hub

Kali Toolkit

Toolkit home (145 scripts) Foundations Network recon Defensive monitoring Vulnerability scanning Enumeration System hardening

Termux tool guides

Apache Brutus Cloudflare Cool Commands Cpp Findomain Fsociety Geo Recon Ghost Eye Hacktronian Ipicker Javascript John Local Server Manjaro Naabu Ncat Nmap Nordvpn Onex Pydictor Python Quasar Recondog Subfinder Termux Banner Ubuntu Gui Wafw00F Web Recon

Learn

Home Termux cheatsheet Python JavaScript C++ Cool Termux commands About Termux Hub