Good day!
I want to create a function wherein I need to use JSON in accessing my objects.
Sample code is as follows:
var dotSlideObject1 = {
show : 3,
length: 2,
id: "#test"
};
var dotSlide = var dotSlideObject1;
function dynamicList(){
var toShow = dotSlide.id+dotSlide.show;
$(toShow).show();
}
I want to reuse the function dynamicList() using another object. eg.
var dotSlideObject2 = {
show : 3,
length: 2,
id: "#huhuhu"
};
var dotSlide = var dotSlideObject2;
But if i use it on the same page, how would it know which object to run?
$(document).ready(function(){
dynamicList();
});
What i want is to make the function reusable even if i used the JSON object.
How can i achieve this?
Thank you.
Use arguments instead of globals.
and