Scratch for Discord
Web-ApplicationDiscord Server
  • 🏠Home
  • 👋Introduction
    • About Scratch for Discord
  • 🎓Tutorial
    • Block Usage
    • Bot Setup
    • Hosting
    • Slash Commands
  • 🧰Toolbox
    • 💼Base
    • ⚽Basic
      • Text
      • Math
      • Colors
    • 🔩Functions
      • Logic
        • If logic
        • State Machines
      • Loops
      • Lists
      • Variables
        • Var
        • Let and Const
      • Functions
      • Collections
      • Buffers
      • Objects
      • 💾Database
      • 📂Files
        • 🖼️Images
          • 📬Member Cards
      • 🔑Securing
    • 🖥️Discord
      • 🎨Embeds
      • 📻Interactions
        • ⚒️Slash
          • 📤Actions
            • 🧱Stacks
            • 🔎Reporters
          • 📥Events
        • Button
        • Menu
        • Context menu
        • Forms
      • 🥁Music
        • 📜Music Lyrics
      • 🗄️Servers
        • 😀Emojis & Stickers
          • 📤Actions
          • 📤Events
        • 🔰Roles
          • 📤Actions
            • 🧱Stacks
            • ❔Booleans
          • 📤Events
        • 🗓️Schedule events
          • 📤Actions
          • 📤Events
        • 📺Channels
          • 📤Actions
          • 📥Events
        • 💬Messages
          • 📤Actions
            • 📝Messages
            • 📢Threads
            • 🔗Webhooks
            • 🥳Reactions
          • 📥Events
          • 🔎Reporters
            • 📌Message Context
        • 👥Members
          • 📤Actions
          • 📥Events
            • 📭Leave
    • 🚀Applications
      • 📊Charts
    • 🌐Websites
      • Dashboard
  • 🖥️Interface
    • ⚙️Settings
    • ⌨️Hotkeys
    • ▶️Download & Run
    • 🖇️Git
  • 🪄Advanced
    • Custom Code
  • 🔗Links
    • 📦Packages
    • ❔FAQ
    • Web-Application
    • Discord Server
    • Source Code
Powered by GitBook
On this page

Was this helpful?

Edit on GitHub
  1. Toolbox
  2. Functions
  3. Variables

Var

PreviousVariablesNextLet and Const

Last updated 1 year ago

Was this helpful?

Var is a variable that allows you to set the variable and be able to redefine it multiple times, below is an example of redefining variables

var x = 200
x = 300

//I declared x once then redeclared it and set the new value to 300!

This variable type is useful because it allows us to reuse it multiple times, unlike other variable types like let, and const which cannot be redeclared more than once.

So we can create a variable, that will be set when the bot starts, named MyName and set it to John, notice we have redeclared this variable now it is no longer John!, then we print the new variable value which will output as Anny.

Output
Anny
🧰
🔩
Example of variable usage