JavaScript 选项哈希使用jQuery

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了JavaScript 选项哈希使用jQuery相关的知识,希望对你有一定的参考价值。

var complex = function(valA, options){
		/**
		 * Set the default values in the object, then extend it to include the
		 * values that we passed to it.
		*/
		var settings = $.extend({
			option1: null,
			option2: null,
			option3: null,
			option4: null
		},options||{});//If no options, pass an empty object
		console.warn(valA);
		console.log(settings.option1);
		console.log(settings.option2);
		console.log(settings.option3);
		console.log(settings.option4);
	};
	complex('Value A', {option1: 'this is option 1'});

以上是关于JavaScript 选项哈希使用jQuery的主要内容,如果未能解决你的问题,请参考以下文章