FerchoCarcho FerchoCarcho - 3 months ago 9
Javascript Question

Console.log the result of a function set Into a Variable

Meanwhile learning how to debug I need to see in the browser the result of an Operation Saved into a variable.

var res= function() {
[].forEach.call(this.slider, function(el) {
return el.className = 'item';
})}.bind(this);


this.slider has the following:
enter image description here

if I
console.log (res)

I get :

enter image description here

I would like to Receive the Changes made to this.slider inside the res function so I could compare the Original and the new value.

Answer

Literally just log before and after the code that manipulates your object:

var res = function() {
    console.log('before:', this.slider);

    [].forEach.call(this.slider, function(el) {
        return el.className = 'item';
    });

    console.log('after:', this.slider);
}.bind(this);
Comments