Pass arguments to console.log as first class arguments via proxy function

This should do it ..

function log() {
    if(typeof(console) !== 'undefined') {
        console.log.apply(console, arguments);
    }
}

Just adding another option (using the spread operator and the rest parameters – although arguments could be used directly with the spread)

function log(...args) {
    if(typeof(console) !== 'undefined') {
        console.log(...args);
    }
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)