javascript - 从单词中获取对象值
问题描述
假设我在 JS 文件中有这个对象:
const persons = [
{
name: 'John Doe',
picture: 'https://images.google.com',
year: '1971'
},
{
name: 'Peter Doe',
picture: 'https://images.google.com',
year: '1981'
}]
如何仅使用名称作为关键字来获取整个对象列表(名称、图片和年份)?就像如果名字是 John Doe 它只得到 John Doe 的名字、照片和年份?
解决方案
推荐阅读
- r - 将两个 R maps() 并排放置
- sql-server - sp_column 不考虑@Column_name
- doxygen - Doxygen - 如何在页面中包含代码文件
- android - 如何在android中viewpager的空视图下方获取触摸事件
- c++ - 以与 Unity 相同的方式将 C++ 脚本添加到 Unreal 中的对象?
- h2o - h2o 模型如何确定用于预测的列(位置、名称等)?
- excel - Excel 365 数据连接数据源=$Workbook$
- ruby-on-rails - ActiveRecord 按来自多个表的列排序
- gdb - GDB 无法创建断点
- android - ListView中的Android自定义ArrayAdapter,ListView onClick适用于模拟器但不适用于手机