Skip to content

Instantly share code, notes, and snippets.

View bluepnume's full-sized avatar

Daniel Brain bluepnume

  • OneText
  • San Jose
View GitHub Profile
var DEFAULT_TOTAL = 10;
var total = 5;
function getTotal() {
"use strict";
if (!total) {
var total = DEFAULT_TOTAL;
}
function foo() {
"use strict";
console.log(x);
var x = 1;
}
use-before-define.js
#1 'x' was used before it was defined.
var DEFAULT_TOTAL = 10;
var total = 5;
function getTotal() {
"use strict";
if (!total) {
var total = DEFAULT_TOTAL;
}
var DEFAULT_TOTAL = 10;
var total = 5;
function getTotal() {
"use strict";
if (!total) {
var total = DEFAULT_TOTAL;
}
<script src="https://www.paypalobjects.com/api/checkout.js"></script>
<div class="container">
<p>Choose your method of payment: </p>
<form>
<div class="radio resize">
<label>
<input type="radio" name="paymentOption" value="paypal" checked>
<img src="../img/payWithPaypal.jpg" alt="Pay with Paypal" class="paymentOptions" width="55" height="40">
</label>
var serialAsyncMap = function () {
var _ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee(collection, fn) {
var result, _iterator, _isArray, _i, _ref2, item;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
result = [];
_iterator = collection, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();
async function makePizza(sauceType = 'red') {
let dough = makeDough();
let sauce = makeSauce(sauceType);
let cheese = grateCheese((await sauce).determineCheese());
(await dough).add(await sauce);
(await dough).add(await cheese);
return await dough;

xcomponent api

xcomponent.create({ ...options })

Create a component definition, which will be loaded in both the parent and child windows.

options

tag string [required]

// Create a 'once' function that generates a new function which can only be called once
function sayHello() {
console.log('hello');
}
var sayHelloOnce = once(sayHello);
sayHelloOnce(); // logs 'hello'
sayHelloOnce(); // does nothing
// Create a 'sayTo' function that lets you "say something to someone" like so:
let sayToJill = sayTo('Jill');
sayToJill.say('hello'); // logs 'hello Jill!'
sayToJill.say('goodbye'); // logs 'goodbye Jill!'