Js USES prototype to call Array's slice method example
- 2020-03-30 03:15:08
- OfStack
<script type="text/javascript">
function fn(name){
if(typeof name === "string"){
var args = Array.prototype.slice.call( arguments, 1 );
for(var i=0;i<args.length;i++){
alert(args[i]);//Result: 111 222
}
}
}
function callFn(){
fn("test",111,222);
}
callFn();
</script>