Skip to content

Instantly share code, notes, and snippets.

View jtulk's full-sized avatar

Justin Tulk jtulk

  • El Paso, Texas
View GitHub Profile
function partial(fn, ...args){
// nothing yet...
}
function basic() {
// nothing yet...
}
partial(basic, 2, 3, 4)
function logPartial(fn, ...args){
console.log(fn, args)
}
function basic() {
return true
}
logPartial(basic,2,3,4)
function logPartial(fn, ...args){
console.log(fn, args)
}
logPartial(1,2,3,4)
>> 1, [2, 3, 4]
function logPartial(fn, a, b, c){
console.log(fn, a, b, c)
}
logPartial(1,2,3,4)
>> 1, 2, 3, 4
@jtulk
jtulk / curry.js
Last active October 8, 2016 20:09
function logPartial(fn, ...args){
console.log(fn, args)
}
logPartial(1,2,3)
>> 1, [2, 3]
@jtulk
jtulk / projectReducer.js
Last active December 20, 2022 07:55
Merge, Dedupe, and Update Arrays in a Redux Reducer
const ADD_PROJECTS = "projects/add_projects"
const initialState = {
projects: []
}
function reducer(state = initialState, action = {}){
switch(action.type){
case ADD_PROJECTS:
@jtulk
jtulk / projectReducer.js
Last active May 20, 2016 21:16
A demo reducer for Redux
const ADD_PROJECTS = "projects/add_projects"
const initialState = {
projects: []
}
export default function reducer(state = initialState, action = {}){
switch(action.type){
case ADD_PROJECTS:
return {
@jtulk
jtulk / script.js
Created September 29, 2015 06:20
Testing for a DOM Element without jQuery
var myCarousel = document.getElementById('myCarousel');
if(myCarousel) {
console.log('Carousel Exists');
} else {
console.log('Carousel Does Not Exist');
}
// 'Carousel Does Not Exist'
@jtulk
jtulk / script.js
Created September 29, 2015 06:10
Testing for a DOM Element
var $myCarousel = $('#myCarousel');
if($myCarousel){
console.log('Carousel Exists');
} else {
console.log('Carousel Does Not Exist Yet');
}
// 'Carousel Exists'
@jtulk
jtulk / script.js
Created September 29, 2015 05:36
Ternary Operator Sample
var foo,
a = 1,
b = 2;
foo = a === b ? 'Matches' : 'Does not match';
console.log(foo); // 'Does not match'