Last active
February 9, 2016 23:26
-
-
Save msecret/42d75e1bd3dba3c1c9da to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var foo = 1; | |
var bar = foo; | |
bar = 9; | |
function doStuff() { | |
var fullName; | |
var item = {}; | |
var items = []; | |
items.push(item); | |
itemsCopy = items.slice(); | |
if (!itemsCopy.length) { | |
return; | |
} | |
if (item.name === 'Bob') { | |
fullName = 'Bob ' + items[0]; | |
} | |
} | |
var errorMessage = 'This is a super long error that was thrown because ' + | |
'of Batman. When you stop to think about how Batman had anything to do ' + | |
'with this, you would get nowhere fast.'; | |
var test; | |
var currentUser = { | |
jedi: true, | |
isGreat: function () { | |
return false; | |
}, | |
'creative-thinker': false, | |
}; | |
if (currentUser) { | |
var isJedi = currentUser.jedi; | |
test = function test(prop) { | |
console.log(isJedi); | |
console.log(currentUser[prop]); | |
}; | |
if (currentUser.name !== 'Bob') { | |
console.log(currentUser.name); | |
} | |
} | |
(function(age) { | |
var name = 'Skywalker'; | |
var hasAge = !!age; | |
return name; | |
})(12); | |
// Can use constructor function or object.create | |
function Person(name) { | |
var _this = this; | |
this._firstName = name; | |
} | |
Person.prototype.setAge = function(age) { | |
this._age = age; | |
}; | |
Person.prototype.getAge = function() { | |
return this._age; | |
}; | |
Person.prototype.toString = function toString() { | |
return 'Jedi - ' + this.getAge(); | |
}; | |
// es6 | |
let count = 1; | |
const b = 2; | |
const items = []; | |
const itemsCopy = [...items]; | |
const atom = { | |
value: 1, | |
addValue(value) { | |
return atom.value + value; | |
}, | |
}; | |
function getFullName({ firstName, lastName }) { | |
return `${firstName} ${lastName}`; | |
} | |
const [first, second] = arr; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment