Skip to content

Instantly share code, notes, and snippets.

View sebdeckers's full-sized avatar
🐑
Hacking on Commons Host

Sebastiaan Deckers sebdeckers

🐑
Hacking on Commons Host
View GitHub Profile
@sebdeckers
sebdeckers / map-entries.js
Created November 24, 2015 03:44
Multiple values with `for ... of`
// Dummy data
var myMap = new Map();
myMap.set("0", "foo");
myMap.set(1, "bar");
myMap.set({}, "baz");
// entries() returns an array of arrays
for (const entry of myMap.entries(myMap))
console.log(entry)
// Console output:
@sebdeckers
sebdeckers / app.js
Last active November 24, 2015 03:40
Object.assign()
import lib from './library'
lib({
foo: false
})
@sebdeckers
sebdeckers / README.md
Created November 23, 2015 16:07
PFNP Live Coding

Programming For Non Programmers

Taught by Sebastiaan Deckers at General Assembly (Singapore).

Lesson 1: Intro to front- and back-end development (2015-11-23)

Links

  • GA Fundamentals introduction to the command line.
  • Nodeschool javascripting workshop to learn the basics of JavaScript.
  • Seb's previous PFNP lesson material. This is much more than can be reasonably covered in 4 evenings with any hope of retetion.
@sebdeckers
sebdeckers / slurp.js
Created November 23, 2015 03:24
Rest arguments & destructuring assignment
// Use a rest argument to slurp remaining data
function slurp (foo, bar, ...baz) {
console.log(baz)
}
slurp(...new Array(10).fill('ha!'))
// Read a range from an array using destructuring assignment
const process = { argv: ['node', 'app.js', 1, 2, 3, 4, 5] }
const [, , ...lol] = process.argv
console.log(lol)
@sebdeckers
sebdeckers / fill.js
Created November 23, 2015 01:08
Array.prototype.fill()
console.log(
new Array(10) // Create an array of 10 undefined elements
.fill('foo') // Replace all the elements with the string 'foo'
)
@sebdeckers
sebdeckers / destructure-vs-spread.js
Created November 20, 2015 00:36
function arguments: array destructuring vs spread operator
var combos = [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]
]
/* function destructures arguments */
function checkWinning ([x, y, z]) {
console.log(x, y, z)
}
@sebdeckers
sebdeckers / for-of.js
Last active November 28, 2015 02:07
for ... of example
const combos = [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]
]
// Iterate over array elements
for (const combo of combos)
console.log(combo)
// Iterate over string characters
@sebdeckers
sebdeckers / questions-actor-player.js
Created November 19, 2015 14:39
Classes in JS Q&A
class Actor {
constructor (x, y, image = sun1) {
this.x = x
this.y = y
this.image = image
}
render () {
context.drawImage(this.image, this.x, this.y)
}
}
@sebdeckers
sebdeckers / coverage-final.json
Created June 23, 2015 14:21
Surfboard coverage
{
"c:\\s\\test\\mocha\\mig-button.js":{"path":"c:\\s\\test\\mocha\\mig-button.js","s":{"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":1,"10":1,"11":1,"12":1,"13":1,"14":1,"15":1,"16":1,"17":1,"18":1,"19":1},"b":{"1":[0,1],"2":[1,1]},"f":{"1":1,"2":1,"3":1,"4":1,"5":1},"fnMap":{"1":{"name":"_interopRequireDefault","line":5,"loc":{"start":{"line":0,"column":0},"end":{"line":0,"column":0}},"skip":true},"2":{"name":"(anonymous_2)","line":15,"loc":{"start":{"line":6,"column":23},"end":{"line":6,"column":29}}},"3":{"name":"(anonymous_3)","line":18,"loc":{"start":{"line":9,"column":9},"end":{"line":9,"column":15}}},"4":{"name":"(anonymous_4)","line":22,"loc":{"start":{"line":13,"column":22},"end":{"line":13,"column":28}}},"5":{"name":"(anonymous_5)","line":25,"loc":{"start":{"line":16,"column":27},"end":{"line":16,"column":33}}}},"statementMap":{"1":{"start":{"line":0,"column":0},"end":{"line":0,"column":0},"skip":true},"2":{"start":{"line":0,"column":0},"end":{"line":0,"column":0},"skip":true},"3":{"start":{"l
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.