Skip to content

Instantly share code, notes, and snippets.

@kotaroito
Last active August 29, 2015 14:05

Revisions

  1. kotaroito renamed this gist Aug 7, 2014. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion jsbin.nopof.js → prototype.js
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,3 @@

    var MyObject = (function() {
    function F() {
    this.keysStartWithLetterA = function () {
  2. kotaroito created this gist Aug 7, 2014.
    10 changes: 10 additions & 0 deletions jsbin.nopof.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>JS Bin</title>
    </head>
    <body>

    </body>
    </html>
    19 changes: 19 additions & 0 deletions jsbin.nopof.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@

    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();