<div id="myDiv"></div>
<script>
String.prototype.supplant = function(o){
return this.replace(/{([^{}]*)}/g,
function (a,b){
var r = o[b];
return typeof r==='string'?r:a;
}
);
};
var template ='<table border="{border}">' +
'<tr><th>Last</th><td>{last}</td></tr>' +
'<tr><th>First</th><td>{first}</td></tr>'+
'</table>';
var data = {
first:"Carl",
last:"Hollywood",
border:"2"
};
myDiv.innerHTML = template.supplant(data);
</script>
请问一下
function (a,b){
var r = o[b];
return typeof r==='string'?r:a;
}
的a,b是怎样传过来的呢?