【发布时间】:2018-11-19 16:26:49
【问题描述】:
我有这段代码,其中需要来自假数据库的用户名:
const MY_FAKE_DB = require('./my_db.js')
const username = 'jdoe2';
const user = MY_FAKE_DB.users[username];
console.log(user.name, user.passwordHash)
而“dataBase”(my_db.js)是下一个:
const users =
{
jdoe2: [{
username: "jdoe2",
name: "Jhoe",
passwordHash: "1234"
}],
lmart: [{
username: "lmart",
name: "Luis",
passwordHash: "2345"
}]
}
我不知道如何从用户那里获取用户名为 jdoe2 的用户。
感谢您的帮助
【问题讨论】:
-
"我不知道怎么从用户那里得到用户名为jdoe2的用户" 写代码就是这样
标签: javascript arrays node.js extract