Jump to content

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


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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...