Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Javascript, what is an options object?

Tags:

Now I have googling this a lot, but I cant seem to find what I am looking for. I am not talking about the options object that does drop down menus, I am talking about seeing stuff like

options.remove, options.enable, options.instance, 

To be honest, I am not sure if the code I am trying to figure out already created some object called "options" or if its a pre-built javascript object. It lights up purple in my dreamweaver editor so I have a feeling its a pre-built object. I am new, sorry.

like image 477
anthonypliu Avatar asked Jun 22 '10 01:06

anthonypliu


People also ask

What is option object used for?

Optional object is used to represent null with absent value. This class has various utility methods to facilitate code to handle values as 'available' or 'not available' instead of checking null values.

How use JavaScript option?

The HTMLOptionElement type illustrates the <option> element in JavaScript. Index- The option's index within the group of options. Selected- It returns a true value if the option is chosen. We set the selected property true for selecting an option.

What is object object in JavaScript?

[object, object] is the string representation of a JavaScript object data type. You'll understand better as we go further in this article. There are two main contexts where you'll encounter such an output: When you try display an object using the alert() method (most common).


1 Answers

An options object is an object passed into a method (usually a method that builds a jQuery widget, or similar) which provides configuration info.

An options object is usually declared using object literal notation:

var options = {
 width: '325px',
 height: '100px'
};

The options that are valid depend on the method or widget that you are calling. There is nothing 'special' about an options object that makes it different from any other javascript object. The object literal syntax above gives the same result as:

var options = new Object();
options.width = '325px';
options.height = '100px';

Example:

$( ".selector" ).datepicker({ disabled: true });
//create a jQuery datepicker widget on the HTML elements matched by ".selector",
//using the option: disabled=true
like image 120
RMorrisey Avatar answered Sep 17 '22 14:09

RMorrisey