diff --git a/docs/js/lang.md b/docs/js/lang.md index a053c256..7c923e82 100644 --- a/docs/js/lang.md +++ b/docs/js/lang.md @@ -1,27 +1 @@ # JavaScript and TypeScript - -You can write micro:bit programs in a subset of [TypeScript](https://www.typescriptlang.org), a superset of JavaScript. -Many micro:bit programs, especially at the beginner's level, are just plain JavaScript. TypeScript introduces class-based -object-oriented programming, such as: - -```typescript -class Greeter { - greeting: string; - constructor(message: string) { - this.greeting = message; - } - greet() { - return "Hello, " + this.greeting; - } -} - -let greeter = new Greeter("world"); -basic.showString(greeter.greet()) -``` - -This site is meant for teaching programming first, and JavaScript second. For this -reason, we have stayed away from concepts that are specific to JavaScript (for -example, prototype inheritance), and instead focused on ones common to most -modern programming languages (lexically scoped variables, functions, classes). -We leverage TypeScript's [type inference](/js/inference) so that -students need not specify types when clear from context. diff --git a/docs/js/operators.md b/docs/js/operators.md index 24851c6a..c2538865 100644 --- a/docs/js/operators.md +++ b/docs/js/operators.md @@ -1,8 +1,11 @@ ## Operators The following JavaScript operators are supported for the micro:bit. + +### ~hint Note that for the micro:bit all arithmetic is performed on integers, rather than floating point. This also is true when simulating in the browser. +### ~ # Assignment, arithmetic and bitwise @@ -22,6 +25,6 @@ This also is true when simulating in the browser. * strings, with a few common methods * [string templates](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals) (`` `x is ${x}` ``) -### ~button /js/controlflow -NEXT: Control Flow +### ~button /js/statements +NEXT: Statements ### ~ \ No newline at end of file diff --git a/docs/js/sequence.md b/docs/js/sequence.md index b9c7613d..90fc1d15 100644 --- a/docs/js/sequence.md +++ b/docs/js/sequence.md @@ -42,11 +42,15 @@ followed by a call to `showNumber` that will never execute: ```typescript while(true) ; basic.showNumber(1); ``` + + +### ~hint For the micro:bit, we don't allow a program to contain an empty statement, such as shown above. If you really want an empty statement, you need to use curly braces to delimit an empty statement block: ```typescript while(true) { } basic.showNumber(1); ``` +### ~ [Read more](http://inimino.org/~inimino/blog/javascript_semicolons) about semicolons in JavaScript. diff --git a/docs/js/variables.md b/docs/js/variables.md index 3dc7c231..1100d135 100644 --- a/docs/js/variables.md +++ b/docs/js/variables.md @@ -116,6 +116,6 @@ const numLivesForCat = 9; They are like `let` declarations but, as their name implies, their value cannot be changed once they are bound. In other words, they have the same scoping rules as `let`, but you can't re-assign to them. -### ~button /js/expressions -NEXT: Expressions +### ~button /js/operators +NEXT: Operators ### ~ \ No newline at end of file