Developers

Table of Content

Table of Content

Table of Content

What is QJS?

Qjs is a family of Large Language Models (LLMs) developed by HP.

Inspired by the Hitchhiker's Guide to the Galaxy, QJS is a maximally truth-seeking AI that provides insightful, unfiltered truths about the universe.

QJS offers an API for developers to programmatically interact with our QJS models. The same models power our consumer facing services such as QJS.com, the iOS and Android apps, as well as QJS in HP experience.

Example:

Want to build with our API?
To access the QJS API, please create an QJS account and an API key

Want to build with our API?
To access the QJS API, please create an QJS account and an API key

Want to build with our API?
To access the QJS API, please create an QJS account and an API key


What is the QJS API? How is it different from QJS in other services?

Single-line comment:

Multi-line comment:




Variables and Constants

Variables store data values and can be declared using var, let, or const.

Declaring Variables

let name = "John"; // String variable
var age = 25; // Number variable
const PI = 3.14; // Constant (cannot be reassigned)
let name = "John"; // String variable
var age = 25; // Number variable
const PI = 3.14; // Constant (cannot be reassigned)
let name = "John"; // String variable
var age = 25; // Number variable
const PI = 3.14; // Constant (cannot be reassigned)
  • let – Block-scoped variable (recommended for most use cases).

  • var – Function-scoped variable (older syntax, avoid using it in modern development).

  • const – Block-scoped, immutable variable (cannot be reassigned).

Variable Naming Rules

  • Must begin with a letter, underscore (_), or dollar sign ($).

  • Cannot use reserved JavaScript keywords.

  • Case-sensitive (myVariable and MyVariable are different).

Data Types in JavaScript

JavaScript is dynamically typed, meaning variables do not have fixed types.

Primitive Data Types

JavaScript has six primitive types:

  • String"Hello"

  • Number42, 3.14

  • Booleantrue, false

  • Undefined – A variable that has been declared but not assigned a value

  • Null – Represents an intentional absence of value

  • Symbol – Unique and immutable identifier (used in advanced programming)

Example:

let text = "JavaScript"; // String
let count = 100; // Number
let isAvailable = true; // Boolean
let value; // Undefined
let empty = null; // Null
let text = "JavaScript"; // String
let count = 100; // Number
let isAvailable = true; // Boolean
let value; // Undefined
let empty = null; // Null
let text = "JavaScript"; // String
let count = 100; // Number
let isAvailable = true; // Boolean
let value; // Undefined
let empty = null; // Null

Non-Primitive (Reference) Data Types

  • Objects – Collections of key-value pairs.

  • Arrays – Ordered lists of values.

  • Functions – Blocks of reusable code.

Example:

let person = { name: "Alice", age: 30 }; // Object
let numbers = [1, 2, 3, 4, 5]; // Array
function greet() { console.log("Hello!"); } // Function
let person = { name: "Alice", age: 30 }; // Object
let numbers = [1, 2, 3, 4, 5]; // Array
function greet() { console.log("Hello!"); } // Function
let person = { name: "Alice", age: 30 }; // Object
let numbers = [1, 2, 3, 4, 5]; // Array
function greet() { console.log("Hello!"); } // Function

Operators in JavaScript

JavaScript includes several types of operators:

Arithmetic Operators

Used for mathematical operations.

let a = 10, b = 5;
console.log(a + b); // Addition (15)
cnsole.log(a - b); // Subtraction (5)
console.log(a * b); // Multiplication (50)
console.log(a / b); // Division (2)
console.log(a % b); // Modulus (0)
let a = 10, b = 5;
console.log(a + b); // Addition (15)
cnsole.log(a - b); // Subtraction (5)
console.log(a * b); // Multiplication (50)
console.log(a / b); // Division (2)
console.log(a % b); // Modulus (0)
let a = 10, b = 5;
console.log(a + b); // Addition (15)
cnsole.log(a - b); // Subtraction (5)
console.log(a * b); // Multiplication (50)
console.log(a / b); // Division (2)
console.log(a % b); // Modulus (0)

Comparison Operators

Used for value comparisons.

console.log(10 > 5); // true
console.log(10 < 5); // false
c0nsole.log(10 == "10"); // true (loose equality)
console.log(10 === "10"); // false (strict equality)
console.log(10 !== 5); // true (not equal)
console.log(10 > 5); // true
console.log(10 < 5); // false
c0nsole.log(10 == "10"); // true (loose equality)
console.log(10 === "10"); // false (strict equality)
console.log(10 !== 5); // true (not equal)
console.log(10 > 5); // true
console.log(10 < 5); // false
c0nsole.log(10 == "10"); // true (loose equality)
console.log(10 === "10"); // false (strict equality)
console.log(10 !== 5); // true (not equal)

Logical Operators

Used to combine multiple conditions.

console.log(true && false); // false (AND)
console.log(true || false); // true (OR)
console.log(!true); // false (NOT)
console.log(true && false); // false (AND)
console.log(true || false); // true (OR)
console.log(!true); // false (NOT)
console.log(true && false); // false (AND)
console.log(true || false); // true (OR)
console.log(!true); // false (NOT)

Conclusion

This page introduced JavaScript syntax, variables, data types, and operators. In the next section, we will explore control flow structures like conditionals and loops to build more complex logic.

Create a free website with Framer, the website builder loved by startups, designers and agencies.