Skip to content

Instantly share code, notes, and snippets.

View obber's full-sized avatar

Kan Adachi obber

View GitHub Profile

Asynchronous Javascript (with callbacks)

Say that we have a function, getRandomDog that runs a callback function asynchronously with a dog object as an argument:

const getRandomName = function() {
  const names = ['puppy', 'buddy', 'sam'];
  return names[Math.floor(Math.random() * names.length)];
};

Take a look:

var a = 'hello';
var b = a;
a = 'world';
console.log(b); // what does this log?

var a = function() {
console.log(this);
};
// unwrapped
console.log(this); // window
// free function invocation
a(); // window
<?php
/**
* Template Name: Lettering Archives
* Description: Used as a page template to show page contents, followed by a loop through a CPT archive
*/
remove_action ('genesis_loop', 'genesis_do_loop'); // Remove the standard loop
add_action( 'genesis_loop', 'custom_lettering_archive_template' ); // Add custom loop