Skip to content

Instantly share code, notes, and snippets.

@mpalpha
mpalpha / destructuring.js
Created August 20, 2019 14:09 — forked from mikaelbr/destructuring.js
Complete collection of JavaScript destructuring. Runnable demos and slides about the same topic: http://git.mikaelb.net/presentations/bartjs/destructuring
// === Arrays
var [a, b] = [1, 2];
console.log(a, b);
//=> 1 2
// Use from functions, only select from pattern
var foo = () => [1, 2, 3];
<?php
/*
Plugin Name: WordPress serves JSON
Description: Serve your content as JSON or JSONP in a simple manner (based on an example by Jon Cave - http://make.wordpress.org/plugins/2012/06/07/rewrite-endpoints-api/).
Plugin URI: https://gist.github.com/lloc/8933914
Author: realloc
Author URI: http://lloc.de/
*/
namespace LLOC\realloc;
function packBox(item){
// Code that puts item in the box
console.log('Put ' +item+ ' in the box');
function addressPackage(address){
// Code that writes the address label
console.log('Addressed the box to ' +address+' and ready to send the '+item+' gift');
}
return addressPackage;
}