`function fn () { let x = 0 if (true) { let x = 1 // only inside this `if` } } `

`const a = 1 `

`let`

is the new `var`

. Constants work just like `let`

, but can’t be reassigned. See: Let and const

`var message = `Hello ${name}` `

`var str = ` hello world ` `

`let bin = 0b1010010 let oct = 0o755 `

`"hello".repeat(3) "hello".includes("ll") "\u1E9B\u0323".normalize("NFC") `

`class Circle extends Shape { `

` constructor (radius) { this.radius = radius } `

` getArea () { return Math.PI * 2 * this.radius } `

` expand (n) { return super.expand(n) * Math.PI } `

` static createFromDiameter(diameter) { return new Circle(diameter / 2) } } `

`const byte = 2 ** 8 // Same as: Math.pow(2, 8) `

*... read the whole story at devhints.io.*

## Linear Algebra in JavaScript with Matrix Operations

Linear Algebra in JavaScript with Matrix Operations

When I recently started to dive into the topic of machine learning, I had to relearn all the things I have studied about linear algebra, stochastic and calculus at school and university. I took a little refresher on matrix operations (addition, subtraction, multiplication and division) in linear algebra and learned about the different types of matrices again: inverse and transpose matrices, and the identity matrix. The article applies those learnings in JavaScript. Furthermore, in the end of the article, there will be a little example to demonstrate why matrices are beneficial for computations in machine learning.

*... read the whole story at www.robinwieruch.de.*

## Using Device Motion on the Web To Detect Shaking

Using Device Motion on the Web · Raymond Camden

I’m currently working on an article for TDN that looks at how web standards have advanced in comparison to the default list of plugins supported for Apache Cordova. In my research, I looked at the Device Orientation API. Specifically, I was interested in device motion. For Cordova, motion and orientation are split into two plugins, but spec-wise, they are covered in - well - one spec. In general, it is a fairly simply API to use. Here is an example from the Mozilla Developer Network page on device motion:

`window.addEventListener('devicemotion', function(event) { console.log(event.acceleration.x + ' m/s2'); }); `

*... read the whole story at www.raymondcamden.com.*

## Using Device Motion on the Web To Detect Shaking

Using Device Motion on the Web · Raymond Camden

I’m currently working on an article for TDN that looks at how web standards have advanced in comparison to the default list of plugins supported for Apache Cordova. In my research, I looked at the Device Orientation API. Specifically, I was interested in device motion. For Cordova, motion and orientation are split into two plugins, but spec-wise, they are covered in - well - one spec. In general, it is a fairly simply API to use. Here is an example from the Mozilla Developer Network page on device motion:

`window.addEventListener('devicemotion', function(event) { console.log(event.acceleration.x + ' m/s2'); }); `

*... read the whole story at mobilewebweekly.com.*

## A Primer on Bézier Curves (A free, online book, several languages)

A Primer on Bézier Curves

In order to draw things in 2D, we usually rely on lines, which typically get classified into two categories: straight lines, and curves. The first of these are as easy to draw as they are easy to make a computer draw. Give a computer the first and last point in the line, and BAM! straight line. No questions asked.

Curves, however, are a much bigger problem. While we can draw curves with ridiculous ease freehand, computers are a bit handicapped in that they can't draw curves unless there is a mathematical function that describes how it should be drawn. In fact, they even need this for straight lines, but the function is ridiculously easy, so we tend to ignore that as far as computers are concerned, all lines are "functions", regardless of whether they're straight or curves. However, that does mean that we need to come up with fast-to-compute functions that lead to nice looking curves on a computer. There's a number of these, and in this article we'll focus on a particular function that has received quite a bit of attention, and is used in pretty much anything that can draw curves: "Bézier" curves

*... read the whole story at pomax.github.io.*