Skip to content

Instantly share code, notes, and snippets.

@mrWinston
Last active February 2, 2016 11:57
Show Gist options
  • Select an option

  • Save mrWinston/348e507891edcb51399a to your computer and use it in GitHub Desktop.

Select an option

Save mrWinston/348e507891edcb51399a to your computer and use it in GitHub Desktop.
Simple Javascript OOP #javascript #nodejs #oop #object
/* This program is free software. It comes without any warranty, to
* the extent permitted by applicable law. You can redistribute it
* and/or modify it under the terms of the Do What The Fuck You Want
* To Public License, Version 2, as published by Sam Hocevar. See
* http://www.wtfpl.net/ for more details.
*/
// import Object
var object = require("./object.js");
//init object
var o = new object();
o.init();
o.hello("hi!");
/* This program is free software. It comes without any warranty, to
* the extent permitted by applicable law. You can redistribute it
* and/or modify it under the terms of the Do What The Fuck You Want
* To Public License, Version 2, as published by Sam Hocevar. See
* http://www.wtfpl.net/ for more details.
*/
/*
Constructor
*/
function Object(){
return this;
}
/*
Method 1: Logs stuff
*/
Object.prototype.hello = function(str){
console.log(str);
};
/*
Method 2: Print stuff
*/
Object.prototype.init = function(){
console.log("initialized");
};
/*
Needed for some reasons...
*/
module.exports = Object
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment