Deck.prototype.get >= 0.1.2

Purpose

Get the value of the wanted key

Syntax

Deck#get ( Stringkey default_value );

Parameters

key
default_value
Optional default value

Examples

Get the value by using a key

var d = new Deck();

// Set a false boolean as the value
d.set('a', false);>>> 0

// undefined is also a valid value to set
d.set('b', undefined);>>> 1

d.set('c', 1);>>> 2

// Now getting those values again
d.get('a');>>> false

d.get('b');>>> undefined

d.get('c');>>> 1

Set a default value if the key hasn't been set yet

var d = new Deck();

d.set('a', false);>>> 0

// Get the value behind key 'a', if it is not set,
// set 'def-value'
d.get('a', 'def-value');>>> false // The value is returned, even though it's a falsy one

// Do the same for an unset key
d.get('b', 'def-value');>>> 'def-value'

// That value remains set
d.get('b');>>> 'def-value'