如何向对象添加具有相同名称的多个属性?

时间:2017-05-16 22:37:52

标签: javascript object

假设我有一个看起来像这样的对象:

sample object view in chrome tools

我希望能够添加包含类似数据的多个public class C { public static void main() { try { File file = new File("C:\\Users\\Sumuel\\Desktop\\Query.xls"); HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet sheet = workbook.createSheet("C.info"); //Create Heading Row rowHeading = sheet.createRow(0); rowHeading.createCell(0).setCellValue("Name"); rowHeading.createCell(1).setCellValue("Email"); rowHeading.createCell(2).setCellValue("Address"); rowHeading.createCell(3).setCellValue("Phone"); for (int i = 0; i < 4; i++){ CellStyle styleHeading = workbook.createCellStyle(); Font font = workbook.createFont(); font.setBold(true); styleHeading.setFont(font); rowHeading.getCell(i).setCellStyle(styleHeading); } for(int i = 0; i<4; i++){ sheet.autoSizeColumn(i); } Customer c1; Row custInfo = sheet.createRow(1); custInfo.createCell(0).setCellValue(c1.getName()); custInfo.createCell(1).setCellValue(c1.getEmail()); custInfo.createCell(0).setCellValue(c1.getAddress()); custInfo.createCell(1).setCellValue(c1.getPhone()); FileOutputStream out = new FileOutputStream(new File("C:\\Users\\Sumuel\\Desktop\\Query.xls")); workbook.write(out); out.close(); workbook.close(); System.out.println("file written"); } catch (Exception e) { System.out.println(e.getMessage()); } } } 属性部分。但是,我不确定在正常的Javascript行为下是否允许这样做。什么是解决这个问题的最佳方法?

1 个答案:

答案 0 :(得分:2)

javascript中的属性名称必须是唯一的!

你想要的,例如,一个&#34;属性部分&#34;对象:

redirect_to charges_shipping_path and return