【文件属性】:
文件名称:fetch-js:从对象或数组中获取值,而不必担心键是否存在
文件大小:4KB
文件格式:ZIP
更新时间:2021-04-27 13:19:36
JavaScript
取值
fetch(obj, key, [default])
object可能包含或可能不包含键的对象
key要搜索的键(字符串或字符串数组)
default -如果键不存在,则可选的回退值
用法
这使得从对象中获取值变得非常简单。 例子:
var fetch = require ( 'fetch-values' ) . fetch ;
var example = {
foo : "bar" ,
baz : "foo" ,
beans : {
test : "value" ,
what : {
is : "going on here"
}
}
} ;
console . log ( fetch ( example , 'foo' ) ) ; // "bar"
console . log ( fetch ( example , 'b
【文件预览】:
fetch-js-master
----index.js(397B)
----package.json(535B)
----LICENSE(6KB)
----README.md(1KB)