Last active
December 10, 2015 10:28
-
-
Save mattjmorrison/4420940 to your computer and use it in GitHub Desktop.
This file contains 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
// Instead of | |
Someframework.object.create({ | |
my: 'attributes', | |
go: 'here' | |
}); | |
// Try doing this | |
function MyObject(){ | |
this.my = "attributes"; | |
this.go = "here"; | |
} | |
Someframework.object.create(new MyObject()); |
This file contains 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
class Person | |
constructor: -> | |
@firstName = "Matt" | |
@lastName = "Morrison" | |
@numbers = [1, 2, 3, 4, 5] | |
@otherThings = | |
one: 1 | |
two: 2 | |
five: 5 | |
doSomething: -> | |
"I'm working on it" | |
console.log(new Person().doSomething()) |
This file contains 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
class Person: | |
def __init__(self): | |
self.first_name = "Matt" | |
self.last_name = "Morrison" | |
self.numbers = [1, 2, 3, 4, 5] | |
self.other_things = {'one': 1, 'two': 2, 'five': 5} | |
def do_something(self): | |
return "I'm working on it" | |
print Person().do_something() | |
# > "I'm working on it" |
This file contains 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
class Person | |
def initialize | |
@first_name = "Matt" | |
@last_name = "Morrison" | |
@numbers = [1, 2, 3, 4, 5] | |
@other_things = {:one => 1, :two => 2, :five => 5} | |
end | |
def do_something | |
"I'm working on it" | |
end | |
end | |
puts Person.new.do_something | |
# > "I'm working on it" |
This file contains 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 Person; | |
Person = (function() { | |
function Person() { | |
this.firstName = "Matt"; | |
this.lastName = "Morrison"; | |
this.numbers = [1, 2, 3, 4, 5]; | |
this.otherThings = { | |
one: 1, | |
two: 2, | |
five: 5 | |
}; | |
} | |
Person.prototype.doSomething = function() { | |
return "I'm working on it"; | |
}; | |
return Person; | |
})(); | |
console.log(new Person().doSomething()); |
This file contains 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 person; | |
person = { | |
firstName: "Matt", | |
lastName: "Morrison", | |
doSomething: function() { | |
return "I'm working on it"; | |
}, | |
otherThings: { | |
five: 5, | |
one: 1, | |
two: 2 | |
}, | |
numbers: [1, 2, 3, 5, 4] | |
}; |
This file contains 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
function Person(){ | |
this.firstName = "Matt"; | |
this.lastName = "Morrison"; | |
this.numbers = [1, 2, 3, 4, 5]; | |
this.otherThings = {one: 1, two: 2, five: 5}; | |
} | |
Person.prototype.doSomething = function(){ | |
return "I'm working on it"; | |
}; | |
console.log(new Person().doSomething()); | |
// > "I'm working on it" |
This file contains 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
person = | |
firstName: "Matt" | |
lastName: "Morrison" | |
doSomething: -> | |
return "I'm working on it" | |
otherThings: | |
five: 5 | |
one: 1 | |
two: 2 | |
numbers: [1, 2, 3, 5, 4,] |
This file contains 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 person = { | |
firstName: "Matt", | |
lastName: "Morrison", | |
doSomething: function(){ | |
return "I'm working on it"; | |
}, | |
otherThings: { // moved up a line | |
five: 5 // moved to first position | |
one: 1, | |
two: 2, | |
} | |
numbers: [1, 2, 3, 5 4,], // Moved 5 to 4th position | |
}; |
This file contains 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
person = { | |
'firstName': "Matt", | |
'lastName': "Morrison", | |
'doSomething': lambda: "I'm working on it", | |
'numbers': [1, 2, 3, 4, 5,], | |
'otherThings': { | |
'one': 1, | |
'two': 2, | |
'five': 5, | |
}, | |
} | |
print person['doSomething']() | |
# > "I'm working on it" |
This file contains 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
person = { | |
:firstName => 'Matt', | |
:lastName => 'Morrison', | |
:doSomething => lambda { "I'm working on it" }, | |
:numbers => [1, 2, 3, 4, 5,], | |
:otherThings => { | |
:one => 1, | |
:two => 2, | |
:five => 5, | |
}, | |
} | |
puts person[:doSomething].call | |
# > "I'm working on it" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment