-
Notifications
You must be signed in to change notification settings - Fork 57
$.extend()
Arthur Guiot edited this page Jul 11, 2017
·
1 revision
This function is SUPER useful when you want to create a function with multiple arguments. This function will merge the arguments the user gave with the default arguments object.
I know it's maybe not clear, so let's take a look at an example 😊!
JS:
var defaults = {
number: 1,
bool: true,
magic: 'real',
animal: 'whale',
croutons: 'delicious'
};
var options = {
number: 2,
magic: 'real',
animal: 'porpoise',
bool: false,
random: 42
};
var settings = $.extend(defaults, options);
console.log(settings);
// Returns: Object{animal: "porpoise", bool: false, croutons: "delicious", magic: "real", number: 2, random: 42}
Don't hesitate to ask your questions
- Home
- The Core Languages
- Getting Started: Installation
- The Basics (
$.var()
+$.target()
) - Developing for DisplayJS
-
$.select()
- Text related
- If...else
$.xss()
$.repeat()
$.custom()
$.live()
$.load()
$.on()
$.onEvent()
$.ready()
- Scroll API
$.all()
$.clone()
$.is()
$.valEmpty()
$.remove()
$.show()
&$.hide()
$.ajax()
- Class Related
$.css()
$.getStyle()
- Fade effects
$.extend()
$.dynamic()
$.parent()
- Elements-Nodes
$.component()
$.time_ago()
$.copy()
$.then()
$.sleep()
$.getProp()