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 / 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 / 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 / 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 / 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 / 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 / app.js
Last active November 24, 2015 03:40
Object.assign()
import lib from './library'
lib({
foo: false
})
@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 / map.js
Last active November 25, 2015 02:19
Map
class Person {
constructor (name, score) {
this.name = name
this.score = score
}
}
const alice_foo = new Person('Alice', 10)
const alice_bar = new Person('Alice', 50)
@sebdeckers
sebdeckers / untitled
Created January 15, 2016 06:26
Untitled
new content
@sebdeckers
sebdeckers / untitled
Created January 15, 2016 06:26
Untitled
new content