Eyad Syria-lover Posted November 14, 2016 Share Posted November 14, 2016 I Want To Create A Function With An Options List Inside It's Parameters,I'am Talking About Something Similar To: counter({ min:0, max:200, mode:"increment" }); Link to comment Share on other sites More sharing options...
davej Posted November 14, 2016 Share Posted November 14, 2016 So what is the problem? Link to comment Share on other sites More sharing options...
Eyad Syria-lover Posted November 14, 2016 Author Share Posted November 14, 2016 How To Create The min,max,and mode Options Inside The Function? Link to comment Share on other sites More sharing options...
Ingolme Posted November 14, 2016 Share Posted November 14, 2016 That is just an object. You can read about objects in the Javascript tutorial: http://www.w3schools.com/js/js_objects.asp Link to comment Share on other sites More sharing options...
davej Posted November 14, 2016 Share Posted November 14, 2016 <!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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now