Skip to content

Keywords Reference

NullScript provides fun, expressive alternatives to standard JavaScript keywords while maintaining full compatibility.

Core Language Keywords

Functions and Variables

NullScriptJavaScriptExample
runfunctionrun greet(name) { ... }
fixedconstfixed PI = 3.14159;
letletlet counter = 0;
varvarvar legacy = "old";

Control Flow

NullScriptJavaScriptExample
whateverifwhatever (condition) { ... }
otherwiseelseotherwise { ... }
sinceforsince (item of items) { ... }
whenwhilewhen (condition) { ... }
switchswitchswitch (value) { ... }
casecasecase "value":
donedefaultdone:
stopbreakstop;
keepgoingcontinuekeepgoing;

Modules

NullScriptJavaScriptExample
useimportuse fs from 'fs';
shareexportshare { myFunction };

Error Handling

NullScriptJavaScriptExample
testtrytest { ... }
grabcatchgrab (error) { ... }
atLastfinallyatLast { ... }
triggerthrowtrigger new Error();

Classes and Objects

NullScriptJavaScriptExample
modelclassmodel MyClass { ... }
__init__constructor__init__() { ... }
inheritsextendsmodel Child inherits Parent
freshnewfresh MyClass();
selfthisself.property
parentsuperparent.method();
foreverstaticrun forever method() { ... }

Async Programming

NullScriptJavaScriptExample
laterasyncrun later fetch() { ... }
holdawaitlet data = hold fetch();

Boolean Values

NullScriptJavaScriptExample
yestruefixed isValid = yes;
nofalsefixed isValid = no;

Other Keywords

NullScriptJavaScriptExample
removedeleteremove obj.property;
whattypeofwhat value
kindinstanceofwhatever (obj kind Array) { ... }
insideinwhatever ("key" inside obj) { ... }
partofsince (item part items) { ... }
nothingvoidnothing 0
usingwithusing (obj) { ... }
freezedebuggerfreeze;
pauseyieldpause value;
gettergetgetter property() { ... }
settersetsetter property(value) { ... }

Examples

Variable Declarations

javascript
// Constants
fixed name = "Alice";
fixed age = 25;
fixed skills = ["JavaScript", "Rust", "NullScript"];

// Variables
let score = 0;
let isPlaying = yes;

// Legacy variables (avoid when possible)
var oldStyle = "not recommended";

Function Definitions

javascript
// Regular function
run calculateArea(length, width) {
  return length * width;
}

// Arrow function (same syntax as JavaScript)
fixed multiply = (a, b) => a * b;

// Async function
run later fetchUserData(id) {
  let response = hold pull(`/api/users/${id}`);
  return hold response.json();
}

// Class method
model Calculator {
  run add(a, b) {
    return a + b;
  }

  run forever multiply(a, b) {
    return a * b;
  }
}

Control Flow Examples

javascript
// Conditional statements
whatever (age moreeq 18) {
  speak.say("You can vote!");
} otherwise whatever (age moreeq 16) {
  speak.say("You can drive!");
} otherwise {
  speak.say("You're still young!");
}

// Loops
since (let i = 0; i less 10; i++) {
  speak.say(`Count: ${i}`);
}

since (fixed item part ["apple", "banana", "cherry"]) {
  speak.say(`Fruit: ${item}`);
}

// While loop
let count = 0;
when (count less 5) {
  speak.say(`Count: ${count}`);
  count++;
}

Error Handling

javascript
run safeDivision(a, b) {
  test {
    whatever (b is 0) {
      trigger fresh fail("Cannot divide by zero!");
    }
    return a / b;
  } grab (error) {
    speak.scream(`Error: ${error.message}`);
    return null;
  } atLast {
    speak.say("Division operation completed");
  }
}

Compatibility Notes

  • All NullScript keywords compile to their exact JavaScript equivalents
  • You can mix NullScript and JavaScript syntax in the same file
  • The transpiler only replaces NullScript keywords, leaving everything else unchanged
  • Output JavaScript is always clean and readable