<A href = "JavaScript:"> a </a> <a href = "JavaScript:"> B </a> <a href = "JavaScript: "> c </a> <a href =" JavaScript: "> d </a> <a href =" JavaScript: "> e </a> <script> var I, s = document. querySelectorAll ("a"); for (I = 0; I <s. length; I ++) s [I]. addEventListener ("click", function () {alert (this); // The first parameter of bind can be obtained using this in the function }. bind (I)/* Here is a parameter for the anonymous callback function bind */); </script>
The bind here is not an event, but a method to bind the function to the default parameter.
<Script type = "text/javascript"> var f, o, fo, name = "SB"; o = {name: "Sub-cobalt carbonate"}; f = function (e) {console. log (this. name + ":" + e)}; fo = f. bind (o, "trembling, human! "); F (" The parameter is valid when called directly! "); Fo (" The parameter here will not be passed to e! "); </Script>
The code shows that the bind changes the original function parameter.
The bind method replaces the closure.