fcf.has() function
Package: fcf-framework-core
File: fcf-framework-core:fcf.js
Available from version: 2.0.2
Checks if an object contains an element with a given key. Also performed for
Arguments
- Checked object
- Checked key
Result
- Returns true if the object contains the given key
If the
Example: Function application
console.log(`Is "k1" in {k1: 1}: `, fcf.has({k1: 1}, "k1"))
console.log(`Is "k2" in {k1: 1}: `, fcf.has({k1: 1}, "k2"))
console.log(`Is 0 in [1]: `, fcf.has([1], 0))
console.log(`Is 1 in [1]: `, fcf.has([1], 1))
{
let map = new Map()
map.set("k1", "v1");
console.log(`Is "k1" in Map({k1: "v1"}): `, fcf.has(map, "k1"))
console.log(`Is "k2" in Map({k1: "v1"}): `, fcf.has(map, "k2"))
}
{
let set = new Set()
set.add("k1");
console.log(`Is "k1" in Set(["k1"]): `, fcf.has(set, "k1"))
console.log(`Is "k2" in Set(["k1"]): `, fcf.has(set, "k2"))
}
Output:
Is "k1" in {k1: 1}: true
Is "k2" in {k1: 1}: false
Is 0 in [1]: true
Is 1 in [1]: false
Is "k1" in Map({k1: "v1"}): true
Is "k2" in Map({k1: "v1"}): false
Is "k1" in Set(["k1"]): true
Is "k2" in Set(["k1"]): false