简体   繁体   English

我如何在 javascript user[0].firstName 中替换为 user.firstName

[英]how do i replace in javascript user[0].firstName with user.firstName

Hello I want to access the information from my object like this您好,我想像这样访问我的对象中的信息

user.firstName

but I'm currently doing it like this但我目前正在这样做

user[0].firstName

I'm using angular js我正在使用角 js

this is the object structure这是对象结构

0: ObjectAccessKey: "example.com"BirthDate: "1969-12-31"CellPhone: "(888) 888-8888"City: "Holtwood"ClosedRegisterAt: nullCompanyId: "1"CreatedAt: "2015-05-31 20:31:00"EditedAt: "2015-05-31 21:32:22"EmergencyContactName: "hhhehee"EmergencyContactPhone: "(717) 444 4344"Employee: "Ben Eshleden"EmployeeId: "8"FirstName: "Ben"LastName: "Eshleden"MailingAddress: "1131 holtwood rd"OpenedRegisterAt: nullPassword: "candoa21"State: "AK"ZipCode: "17532"

use

$.each(user, function (i, eachuser) {
 name = eachuser.firstname;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用变量编写此 RegExp /^\s*FirstName\s*$/? 我想用变量替换 FirstName? - How to write this RegExp /^\s*FirstName\s*$/ using a variable? I want to replace FirstName with a variable? 如何将 firstName 和 lastName 添加到 fullName? - How can I add firstName and lastName to fullName? JS/如何通过名字和姓氏输入进行搜索,但如果我在名字后键入空格也可以工作 - JS/ How to search with input by firstname and lastname but also work if i type space after firstname 我如何在反应中将名字/姓氏更改为名字/姓氏? 问题是它来自后端 - how can i change firstname/lastname to firstName/lastName in react? the problem is that it comes from the backend 如何将 DOM JavaScript 添加到我的 script.js 中,以便在提交 info(firstname, lastname, and age) 时,它会在主页上显示为一个句子? - How do I add DOM JavaScript to my script.js so when info(firstname, lastname, and age) is submitted, it displays on the main page as a sentence? 如何过滤外部 JSON 数据并使用 Javascript 获取名字? - How to filter external JSON data and get firstName using Javascript? Javascript连接名字,姓氏和代码 - Javascript Concatenate FirstName, LastName and Code 如何检查数据库中已经存在的名字并给出错误消息? - How can i check firstname already in the database and give a error message? 如何将具有名字和姓氏的字符串转换为具有 {firstName: "string first name", lastName: "string last name} 属性的对象? - How do I convert a string with a first name and last name to an object w/ properties of {firstName: "string first name", lastName: "string last name}? 验证输入字段 Fullname(Firstname,Lastname) - JavaScript - Validation input field Fullname(Firstname,Lastname) - JavaScript
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM