Skip to main content
Documentation
About FAQ Projects GitHub Support
Courses
CS Intro
About Introduction References Acknowledgements
Making
Introduction Unplugged Walkthrough Project Standards
Algorithms
Overview Unplugged Activity Project Standards
Variables
Overview Unplugged Activity Project Standards
Conditionals
Overview Unplugged Activity Project Standards
Iteration
Overview Unplugged Activity Project Standards
Mini-project
Review Activity Project Standards
Coordinates
Overview Unplugged Activity Project Standards
Booleans
Overview Unplugged Activity Project Standards
Binary
Overview Unplugged Activity Project Standards
Radio
Overview Unplugged Activity Project Standards
Arrays
Overview Unplugged Activity Project Standards
Final Project
Review Project Examples Standards
Blocks to JavaScript
Hello JavaScript Starter Blocks Writing Code Conditional Loops Writing Functions
Science experiments
Data collection
Overview Setup and procedure Resources
Population Traits
Overview Setup and procedure Resources
Temperature
Overview Setup and procedure Resources
Soil Moisture
Overview Setup and procedure Resources
Gravity, Motion and Waves
Overview Setup and procedure Resources
Body Electrical and Waves
Overview Setup and procedure Resources
Electricity
Overview Setup and procedure Resources
Rocket Acceleration
Overview Build Setup and procedure Resources
Reference
Basic
show number show icon show leds show string clear screen forever pause show arrow show animation
Input
on button pressed on gesture on pin pressed button is pressed compass heading pin is pressed temperature acceleration light level rotation magnetic force running time set accelerometer range
Music
play tone ring tone rest beat tempo change tempo by set tempo
Led
plot unplot point toggle brightness set brightness stop animation plot bar graph enable
Radio
send number send value send string on received number on received string on received buffer received packet set group set transmit power set transmit serial number on data packet received write received packet to serial
Game
create sprite delete move turn if on edge bounce get set change is touching is touching edge add score score set score set life add life remove life start countdown game over pause resume
Images
create image create big image show image scroll image arrow image icon image arrow number
Pins
digital read pin digital write pin analog read pin analog write pin analog set period map on pulsed pulse duration pulse in servo write pin servo set pulse i2c read number i2c write number set pull analog pitch analog set pitch pin spi write spi Pins spi format spi frequency
Serial
write line write number write value write string read until read line read string on data received redirect redirect to usb write buffer read buffer
Control
in background reset wait micros on event raise event event timestamp event value
Bluetooth
About Pairing on bluetooth connected on bluetooth disconnected start accelerometer service start button service start io pin service start led service start magnetometer service start temperature service start uart service uart read until uart write string uart write number uart write value advertise url stop advertising advertise uid advertise-uid-buffer
Devices
tell camera to tell remote control to raise alert to on notified on gamepad button signal strength on signal strength changed
Extensions
Blocks
On Start
Loops
repeat for while for of
Logic
if Boolean
Variables
assign change var var
Math JavaScript blocks Custom blocks
Python
Calling Sequencing Variables Operators Statements Functions Classes
JavaScript
Calling Sequencing Variables Operators Statements Functions Types Classes Interfaces Generics
Types
Number String Boolean Array Function
Buffer
Using buffers Number format
Hardware
Data Analysis
Plotting with LEDs Viewing Data Writing Data Generating Data Analyzing Data Remote Data
Error codes Foil circuits MES events Pins Reactive Screen Serial Servo Simulator USB
WebUSB
WebUSB Troubleshoot
Flashing via HID (CMSIS-DAP)
Miscellaneous
About Support Translate Sharing projects Offline support Save
Developers
Command Line Interface Visual Studio Code support Blocks Embed
Projects
Flashing Heart Smiley Buttons Love Meter Rock Paper Scissors Magic Button Trick Coin Flipper Salute! Hack Your Headphones Banana Keyboard Guitar Duct Tape Wallet Watch Soil Moisture Plant Watering Reaction Time States of Matter Mood Radio Tele-Potato Hot or Cold Voting Machine Infection Fireflies Rock Paper Scissors Teams Inchworm Milk Carton Robot Milk Monster RC Car Timing Gates Compass Telegraph Railway Crossing Karel Stopwatch Name Tag Step counter Servo calibrator Analog Pin Tester Light Level Meter Radio bridge Snap the dot Red light green light
DocsJavaScriptStatements
Documentation
About FAQ Projects GitHub Support
Courses
CS Intro
About Introduction References Acknowledgements
Making
Introduction Unplugged Walkthrough Project Standards
Algorithms
Overview Unplugged Activity Project Standards
Variables
Overview Unplugged Activity Project Standards
Conditionals
Overview Unplugged Activity Project Standards
Iteration
Overview Unplugged Activity Project Standards
Mini-project
Review Activity Project Standards
Coordinates
Overview Unplugged Activity Project Standards
Booleans
Overview Unplugged Activity Project Standards
Binary
Overview Unplugged Activity Project Standards
Radio
Overview Unplugged Activity Project Standards
Arrays
Overview Unplugged Activity Project Standards
Final Project
Review Project Examples Standards
Blocks to JavaScript
Hello JavaScript Starter Blocks Writing Code Conditional Loops Writing Functions
Science experiments
Data collection
Overview Setup and procedure Resources
Population Traits
Overview Setup and procedure Resources
Temperature
Overview Setup and procedure Resources
Soil Moisture
Overview Setup and procedure Resources
Gravity, Motion and Waves
Overview Setup and procedure Resources
Body Electrical and Waves
Overview Setup and procedure Resources
Electricity
Overview Setup and procedure Resources
Rocket Acceleration
Overview Build Setup and procedure Resources
Reference
Basic
show number show icon show leds show string clear screen forever pause show arrow show animation
Input
on button pressed on gesture on pin pressed button is pressed compass heading pin is pressed temperature acceleration light level rotation magnetic force running time set accelerometer range
Music
play tone ring tone rest beat tempo change tempo by set tempo
Led
plot unplot point toggle brightness set brightness stop animation plot bar graph enable
Radio
send number send value send string on received number on received string on received buffer received packet set group set transmit power set transmit serial number on data packet received write received packet to serial
Game
create sprite delete move turn if on edge bounce get set change is touching is touching edge add score score set score set life add life remove life start countdown game over pause resume
Images
create image create big image show image scroll image arrow image icon image arrow number
Pins
digital read pin digital write pin analog read pin analog write pin analog set period map on pulsed pulse duration pulse in servo write pin servo set pulse i2c read number i2c write number set pull analog pitch analog set pitch pin spi write spi Pins spi format spi frequency
Serial
write line write number write value write string read until read line read string on data received redirect redirect to usb write buffer read buffer
Control
in background reset wait micros on event raise event event timestamp event value
Bluetooth
About Pairing on bluetooth connected on bluetooth disconnected start accelerometer service start button service start io pin service start led service start magnetometer service start temperature service start uart service uart read until uart write string uart write number uart write value advertise url stop advertising advertise uid advertise-uid-buffer
Devices
tell camera to tell remote control to raise alert to on notified on gamepad button signal strength on signal strength changed
Extensions
Blocks
On Start
Loops
repeat for while for of
Logic
if Boolean
Variables
assign change var var
Math JavaScript blocks Custom blocks
Python
Calling Sequencing Variables Operators Statements Functions Classes
JavaScript
Calling Sequencing Variables Operators Statements Functions Types Classes Interfaces Generics
Types
Number String Boolean Array Function
Buffer
Using buffers Number format
Hardware
Data Analysis
Plotting with LEDs Viewing Data Writing Data Generating Data Analyzing Data Remote Data
Error codes Foil circuits MES events Pins Reactive Screen Serial Servo Simulator USB
WebUSB
WebUSB Troubleshoot
Flashing via HID (CMSIS-DAP)
Miscellaneous
About Support Translate Sharing projects Offline support Save
Developers
Command Line Interface Visual Studio Code support Blocks Embed
Projects
Flashing Heart Smiley Buttons Love Meter Rock Paper Scissors Magic Button Trick Coin Flipper Salute! Hack Your Headphones Banana Keyboard Guitar Duct Tape Wallet Watch Soil Moisture Plant Watering Reaction Time States of Matter Mood Radio Tele-Potato Hot or Cold Voting Machine Infection Fireflies Rock Paper Scissors Teams Inchworm Milk Carton Robot Milk Monster RC Car Timing Gates Compass Telegraph Railway Crossing Karel Stopwatch Name Tag Step counter Servo calibrator Analog Pin Tester Light Level Meter Radio bridge Snap the dot Red light green light
DocsJavaScriptStatements

Statements

The following JavaScript statements are supported for the micro:bit:

Variable declarations

  • const statement
  • let statement

Block-structured statements

  • { } block statement
  • if-else conditional statement
  • while loop
  • do-while loop
  • for(;;) loop
  • switch statement (on numbers only)

Control-flow commands

  • break statement
  • continue statement
  • return statement
  • debugger statement for breakpoints

Labeling statements

  • label: statement
  • default statement

Edit this page on GitHub
Edit template of this page on GitHub
Edit template of this page on GitHub

Privacy & Cookies Terms Of Use Trademarks
© 2018 Microsoft
Powered by Microsoft MakeCode