Last active
August 29, 2015 14:05
-
-
Save kotaroito/351a8be47c33b403b544 to your computer and use it in GitHub Desktop.
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
</body> | |
</html> |
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 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