Caspert Caspert - 4 months ago 7
Javascript Question

How to use two types of parameters within a function?

I call the following function to create a new css object:

set(
dot, {
x: mX,
y: mY,
force3D: !0
}
);


set: function(el) {
alert(el);

var dot = $(el).css('-webkit-transform', 'translate3d(' + x + ', ' + y + ', ' + z + ')');
return dot;
}


Now I was wondering how to get the first parameter of the function set, to be more precise: dot.
I already tried: alert(el); but this will give me an alert with [object Object].
I know you can access the object options by using
el.x
, but how to access the first parameter I doesn't know.

Can someone help me out. Thanks a lot!

Answer

Is this what you're trying to do?

set = function(el) {
    console.log(el.x); // You can access the properties like this
    console.log(el.y);
    console.log(el.force3D);
    
    return dot;
};

// Build the params
var dot = {
    x: 'asdf',
    y: 'asdf',
    force3D: !0
};

// Call the set() method
set(dot);