Last active
August 29, 2015 14:11
-
-
Save seanstrom/bced5c4f6f494f8dceba to your computer and use it in GitHub Desktop.
Exploring Constructors and Factories in Javascript - Constructor Without New Example
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 Person = require('./person') | |
console.log(name) // undefined | |
console.log(age) // undefined | |
var sean = Person('Sean Hagstrom', 20) | |
console.log(sean) // undefined | |
console.log(name) // Sean Hagstrom | |
console.log(age) // 20 |
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
function Person(name, age) { | |
this.name = name | |
this.age = age | |
} | |
module.exports = Person |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment