Skip to content

Instantly share code, notes, and snippets.

@kotaroito
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kotaroito/351a8be47c33b403b544 to your computer and use it in GitHub Desktop.
Save kotaroito/351a8be47c33b403b544 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
</body>
</html>
var MyObject = (function() {
function F() {
this.keysStartWithLetterA = function () {
for (var key in this) {
if ( key.substring(0,1) === "a" )
console.log(key);
}
};
}
return function(proto) {
F.prototype = proto;
var f = new F();
return f;
};
})();
var obj = MyObject({foo:1, a1: 1});
obj.keysStartWithLetterA();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment