Https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call
functionProduct (name, price) { This. Name =name; This. Price =Price ;}functionFood (name, price) {Product.call ( This, name, price); This. Category = ' food ';}functionToy (name, price) {Product.call ( This, name, price); This. Category = ' toy ';}varCheese =NewFood (' feta ', 5);varFun =NewToy (' robot ', 40);
var animals = [{species: ' Lion ', name: ' King ' }, {species: ' Whale ', Name: ' Fail ' }]; for (var i = 0; i < animals.length; I++ Span style= "COLOR: #0000ff" >function (i) { This . Print = function () {Console.log (/ span> ' # ' + i + ' + this .species + ': ' + this .name); this .print (); }). Call (Animals[i], i);}
function greet () { var reply = [This] role].join ('); Console.log (reply);} var i = { ' Douglas crockford ', role: ' Javascript Developer '// Douglas Crockford is an Awesome Javascript Developer
Js--call ()/apply ()/bind ()--Apply