codesha
codesha

Reputation: 23

How to console log an option of a JS object?

I would like to know how to console the value output of an option. In the example provided it would be the value of propOne, displayed here as 'value'. Thanks

var loadParallax = function(){
    $('.class-selector').parallax({
    propOne: 'value'
});

Upvotes: 2

Views: 104

Answers (2)

Márius Rak
Márius Rak

Reputation: 1472

For start, you should look into documentation for the plugin and search for something like getter, or options. Since you didn't state what plugin you use, I'll just give some tips, that could be useful.

Many plugins do this by method .option('name_of_option') or .get('name_of_option') or .method('get', 'name_of_option') so you can try for example loadParallax.get('name_of_option'). You can also try directly access the option as a property of object so you type loadParallax.name_of_option but many plugins disallows this.

Upvotes: 0

agconti
agconti

Reputation: 18093

You need a reference to the passed in options object, then you can log it:

var options = {
    propOne: 'value'
};
var loadParallax = function(){
    $('.class-selector').parallax(options);
};

console.log(options.propOne); // => 'value'

Upvotes: 5

Related Questions