##Sites
JS the right way
Links to tools, readings, podcast, frameworks, news etc
You might not need jQuery
A transition from jQuery to vanilla JS
JavaScript for cats
Entry level JS
function hostReachable() { | |
// Handle IE and more capable browsers | |
var xhr = new ( window.ActiveXObject || XMLHttpRequest )( "Microsoft.XMLHTTP" ); | |
var status; | |
// Open new request as a HEAD to the root hostname with a random param to bust the cache | |
xhr.open( "HEAD", "//" + window.location.hostname + "/?rand=" + Math.floor((1 + Math.random()) * 0x10000), false ); | |
// Issue request and handle response |
function *write(){ | |
console.log('writing'); | |
var num = yield 1; | |
console.log('num x num =', num * num); | |
} | |
function *blah () { | |
console.log('starting blah'); | |
yield* write(); | |
console.log('ending blah'); |
// Thunk | |
let get = function (url) { | |
// return a function, passing in our callback | |
return function (callback) { | |
let xhr = new XMLHttpRequest(); | |
xhr.open('GET', url); | |
xhr.onreadystatechange = function() { | |
let response = xhr.responseText; | |
if(xhr.readyState != 4) return; |
"use strict"; | |
const port = process.env.PORT || 1337; | |
const koa = require('koa'); | |
const app = koa(); | |
app.use(function* (){ | |
/* this */ |
// ES6 for loops | |
// ============= | |
// Things in ES6 can be "iterable". Arrays are iterable by default. | |
var fruits = ['Apple', 'Banana', 'Grape']; | |
for (var fruit of fruits) | |
console.log('Fruit: ' + fruit); |
##Sites
JS the right way
Links to tools, readings, podcast, frameworks, news etc
You might not need jQuery
A transition from jQuery to vanilla JS
JavaScript for cats
Entry level JS
var test = require('tape'); | |
var request = require('supertest'); | |
var server = require('../../server'); | |
test('barcode route', function(t) { | |
request(server) | |
.get('/api/1/code') | |
.expect(200) | |
.expect('Content-Type', /json/) | |
.expect({"code":{"code":"1M4A67AE3H94RS6GG74M"}}) |
@mixin ie6 { * html & { @content } } | |
#logo { | |
background-image: url("/images/logo.png"); | |
@include ie6 { background-image: url("/images/logo.gif"); } | |
} |