Skip to content

Instantly share code, notes, and snippets.

View bellentuck's full-sized avatar

Ben Ellentuck bellentuck

  • New York, NY
View GitHub Profile
//run this in your console
for (var i = 0; i <= 3; i++) {
  setTimeout(function(){
    console.log(i); 
  }, 0); 
} 
@bellentuck
bellentuck / isFalsy.js
Created January 26, 2018 17:07 — forked from skoshy/isFalsy.js
Determines if any value is "falsy" in JavaScript
// this function takes in any parameter and can tell if it's "falsy" or not.
// falsy means it's either false, 0, null, undefined, NaN, or an empty string/array/object
// see the test cases at the bottom for a clearer picture
function isFalsy(item) {
try {
if (
!item // handles most, like false, 0, null, etc
|| (
typeof item == "object" && (
@bellentuck
bellentuck / types.js
Created January 24, 2018 19:14 — forked from pbakondy/play.js
Play with Object.prototype.toString.call()
// under Google Chrome 36
Object.prototype.toString.call([])
// "[object Array]"
Object.prototype.toString.call(function(){})
// "[object Function]"
Object.prototype.toString.call({})
// "[object Object]"
Object.prototype.toString.call(null)
// "[object Null]"
@bellentuck
bellentuck / vector.js
Created January 23, 2018 03:30 — forked from kj786/vector.js
Implement getters and setters to ease access to private members of Vector.
/*global console: true */
"use strict";
/*
A vector type
Write a constructor Vector that represents a vector in two-dimensional
space. It takes x and y parameters (numbers), which it should save to
properties of the same name.
Give the Vector prototype two methods, plus and minus, that take another vector as a parameter and return a new vector that has the sum
or difference of the two vectors’ (the one in this and the parameter) x
and y values.
@bellentuck
bellentuck / undirected-graph.js
Created January 31, 2017 17:51 — forked from Cfeusier/undirected-graph.js
Simple undirected graph implementation in JavaScript
var Graph = function() {
this.nodes = {};
this.edges = {};
};
Graph.prototype.addNode = function(node) {
this.nodes[node] = node;
};
Graph.prototype.contains = function(node) {
body {
font-family: 'HelveticaNeue-UltraLight', 'Helvetica Neue UltraLight', 'Helvetica Neue', Arial, Helvetica, sans-serif;
font-weight: 100;
letter-spacing: 1px;
}
@bellentuck
bellentuck / basicBootstrapHTMLTemplate.html
Created October 18, 2016 19:25 — forked from joechan3/basicBootstrapHTMLTemplate.html
joechan3's Basic Bootstrap Template using CDNs (from Lynda.com - Course: Bootstrap Essentials Training-Ray Villalobos)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/style.css">
<!--Picturefill-->