Skip to content

Instantly share code, notes, and snippets.

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?

View this-keyword-examples.js
var a = function() {
// unwrapped
console.log(this); // window
// free function invocation
a(); // window
View lettering-archive.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
You can’t perform that action at this time.