Jump to content

How Can I Create A Function With An Option In It's Parameter?


Eyad Syria-lover

Recommended Posts

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Test</title>

<style>

</style>

<script>

window.onerror = function(a,b,c){

alert('Javascript Error: '+a+'\nURL: '+b+'\nLine Number: '+c);

return true;

}

</script>

</head>

<body>

<h1>Test</h1>

<script>

counter();

counter({mode:"stopped"});

counter({

min:0,

max:200,

mode:"increment"

});

 

function counter(o){

if( o instanceof Object ){

if(o.min != undefined && o.min != null){

alert('min= ' + o.min);

}

if(o.max != undefined && o.max != null){

alert('max= ' + o.max);

}

if(o.mode != undefined && o.mode != null){

alert('mode= ' + o.mode);

}

}else{

alert('Error: counter parameter ['+ o +'] is not an object');

}

}

</script>

</body>

</html>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...