Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
The no framework JS framework
//persons module
persons = (function(){
//private Person object constructor
var Person = function(firstName, lastName, birthDate){
var foo = "bar";
var name = function(){
return firstName + " " + lastName;
var age = function(){
var currentYear = (new Date()).getYear()
var birthDayYear = birthDate.getYear()
return currentYear - birthDayYear
var saySomething = function(){
return foo;
//the methods that will be public
return {
"name": name,
"age": age,
"saySomething": saySomething
//private FitnessAddict object constructor
var FitnessAddict = function(firstName, lastName, birthDate, weight, height){
var person = Person(firstName, lastName, birthDate);
var bmi = function(){
return weight / (height*height);
var isWeightNormal = function(){
var currentBmi = bmi()
if(currentBmi > 25){
return false
if(currentBmi < 18.5){
return false
return true
//we make isWeightNormal method public
person.isWeightNormal = isWeightNormal;
return person;
//we make the fitnessAddict object constructor public
return {
"FitnessAddict": FitnessAddict
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.