讲伪数组转化成数组||定义一个log代替console.log

来源:互联网 发布:数据库原理概论pdf 编辑:程序博客网 时间:2024/06/16 13:59

//讲伪数组转化成数组

function log(){

      var args = Array.prototype.slice.call(arguments);  //为了使用unshift数组方法,将argument转化为真正的数组
      args.unshift('(app)');
      console.log.apply(console, args);
    };

log("hello world")


// 定义一个log代替console.log

function log(){
    console.log.apply(console, arguments);
};