<commit_before><!DOCTYPE html>
<html lang="en-US">
    <head>
        <meta charset="UTF-8"/>
        <title>ECMAScript 5</title>
        <script>
(function() {
    var o = {name: "dog"};
    var o2 = {name: "cat"};
    function test() { console.log(this.name); };
    
    // The bind function method returns a function (doesn't modify the original
    // function) that has its "this" reference permanently bound to the object
    // passed into bind.
    var bound_test = test.bind(o);
    
    // bound_test will only ever reference o as this.
    // All results should be dog.
    // The original test function is not modified, just the returned,
    // bound function.
    bound_test();
    bound_test.call(o2);
    o2.meth = bound_test;
    o2.meth();
})();
        </script>
    </head>
    <body>
        <header>
            <h1>Function type changes</h1>
            <strong>(Please open up the code to walk through the examples.)</strong>
        </header>
    </body>
</html><commit_msg>Document some unexpected behavior with function.bind.<commit_after><!DOCTYPE html>
<html lang="en-US">
    <head>
        <meta charset="UTF-8"/>
        <title>ECMAScript 5</title>
        <script>
(function() {
    var o = {name: "dog"};
    var o2 = {name: "cat"};
    var test = function() { console.log(this.name); };

    // The bind function method returns a function (doesn't modify the original
    // function) that has its "this" reference permanently bound to the object
    // passed into bind.
    var bound_test = test.bind(o);

    // bound_test will only ever reference o as this.
    // All results should be dog.
    // The original test function is not modified, just the returned,
    // bound function.
    bound_test();
    bound_test.call(o2);
    o2.meth = bound_test;
    o2.meth();


    // Note to future self:
    // After some experiments, the bind function is finicky and seems to be
    // less tolerant of "function objects" as I've become used to in other
    // JavaScript code where I make use of functions-as-objects.
    // Note the weird (to me) behavior below.
    var f = function() {
        console.log("this.prototype", this.prototype);
        //console.log("this.prototype.constructor", this.prototype.contructor);
        console.log("this is:", this.toString());
        console.log("this.name is:", this.name);
        this.name = "internal name.";
    };
    f.prototype.name = "my name is f.prototype.name.";
    f.name = "my name is f().";
    var g = f.bind(f);
    g.name = "my name is g().";
    console.log("static call g():");
    g();
    console.log("new g()");
    new g();
})();
        </script>
    </head>
    <body>
        <header>
            <h1>Function type changes</h1>
            <strong>(Please open up the code to walk through the examples.)</strong>
        </header>
    </body>
</html>
{'fraction_non_alphanumeric': 0.14180929095354522, 'fraction_numerical': 0.005588543485853999, 'mean_word_length': 2.326364692218351, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2537617', 'n_tokens_mistral': 874, 'n_tokens_neox': 849, 'n_words': 290}