Skip to content

Instantly share code, notes, and snippets.

let objOne = {name: 'avery', height: 6};
let objTwo = {...objOne, height: 4};
console.log(objOne, objTwo);
// {name: "avery", height: 6} {name: "avery", height: 4}
let objOne = {name: 'buck', height: 6};
objOne.name = 'avery'; // object mutated
// non-mutation with assign method
// don't forget the empty object as the first parameter
let objTwo = Object.assign({}, objOne, {height: 4});
console.log(objOne, objTwo);
// {name: "avery", height: 6} {name: "avery", height: 4}
let arrOne = [1, 2, 3];
let arrTwo = [...arrOne, 4];
console.log(arrOne, arrTwo);
// [1, 2, 3] [1, 2, 3, 4]
let arrThree = [-1, 0, ...arrTwo];
console.log(arrThree);
// [-1, 0, 1, 2, 3, 4]
let myArr = [1, 2, 3];
console.log(...myArr);
// 1 2 3
let myArr = [1, 2, 3];
console.log(myArr);
// [1, 2, 3]
myArr.push(4);
console.log(myArr);
// [1, 2, 3, 4]
@captDaylight
captDaylight / tween.js
Created August 31, 2015 14:16
Simple Tween
function tween(finalPos, prevPos, tweenRatio) {
if (finalPos === prevPos) {
return prevPos;
} else {
let dist = Math.abs(finalPos - prevPos);
if (dist < 0.005) {
// set to final position when getting close
return prevPos;
} else {
console.log('test');
@captDaylight
captDaylight / gist:9212492
Created February 25, 2014 16:33
show_view
SpreeStore.module('Products.Show',function(Show, SpreeStore, Backbone,Marionette,$,_){
Show.Product = Backbone.Marionette.ItemView.extend({
tagName: 'div',
className: 'product',
template: "#product-template",
events: {
"click button": "addToCart",
"click #product-quantity-list li.quantity-drop": "selectQuantity",
"click #frequency-quantity-list li.quantity-drop": "selectFrequency",
MADPRESS.About = {
init: function(data, callback) {
},
index: function(data, callback) {
var scrolling = false;
$('#about-side-nav').localScroll({ duration: 1000, onAfter: function() {
MADPRESS.About = {
init: function(data, callback) {
},
index: function(data, callback) {
var scrolling = false;
$('#about-side-nav').localScroll({ duration: 1000, onAfter: function() {