Javascript 从对象获取值总是返回未定义的值

Javascript 从对象获取值总是返回未定义的值,javascript,json,typescript,object,Javascript,Json,Typescript,Object,我有下面的对象,我已经打印为json {"36":92,"38":93,"40":98,"41":16,"42":13,"43":38,"44":64,"45":94,"46":85,"47":100,"48":21,"49":33,"50":59,"51":79,"52":81,"53":14,"54":60,"55":103,"56":44,"57":24,"58":28,"59":65,"60":99,"61":23,"62":2,"63":31,"64":74,"65":110,"66"

我有下面的对象,我已经打印为json

{"36":92,"38":93,"40":98,"41":16,"42":13,"43":38,"44":64,"45":94,"46":85,"47":100,"48":21,"49":33,"50":59,"51":79,"52":81,"53":14,"54":60,"55":103,"56":44,"57":24,"58":28,"59":65,"60":99,"61":23,"62":2,"63":31,"64":74,"65":110,"66":97,
"67":17,"68":43,"69":72,"70":95,"71":111,"72":56,"73":4,"74":46,"75":86,"76":114,"77":5,"78":20,"79":57,"80":104,"81":75,"82":18,"83":66,"84":77,"85":19,"86":49,"87":36,"88":91,"89":25,"90":70,"91":107,"92":55,"93":108,"94":10,"95":48,
"96":54,"97":22,"98":9,"99":42,"100":58,"101":29,"102":82,"103":102,"104":78,"105":34,"106":52,"107":50,"108":0,"109":83,"110":89,"111":12,"112":68,"113":96,"114":88,"115":47,"116":6,"117":109,"118":30,"119":39,"120":73,"121":63,"122":
69,"123":87,"124":53,"125":61,"126":106,"127":15,"128":26,"129":71,"130":37,"131":51,"132":7,"133":1,"134":80,"135":76,"136":101,"137":8,"138":105,"139":84,"140":113,"141":40,"142":3,"143":35,"144":62,"145":27,"146":67,"147":45,"148":1
12,"149":90,"150":11,"151":41,"152":32}
但是获取say“149”的值总是返回未定义的值。我不确定是什么导致了这个问题

我需要一个映射,其中产品id映射到它在数组中的位置

const productsInFormat: ProductInFormatImpl[] = [];
const productMap = {};
for (const product of products) {
  const productIndex = productMap[product.productId];
  if (!(productIndex === undefined || productIndex === null)) {
    ("DO SOmething here");
  } else {
    const arrayLength = productsInFormat.push(productInFormat);
    productMap[product.productId] = arrayLength - 1;
  }
}

请发布一篇文章,以便我们能够准确地看到错误是如何发生的。const productsInFormat:ProductInFormatImpl[]=[];const productMap={};对于(产品的常量乘积){const productIndex=productMap[product.productId];if(!(productIndex==undefined | | productIndex==null)){在这里做点什么}其他{const arraylelength=productsInFormat.push(productInFormat);productMap[product.productId]=arraylelength-1;}这里productIndex总是返回undefinedYour对象的内部有无效的换行符,因此除了绝对不可读之外,它的语法也不正确。我复制了您的对象示例,而值148是一个错误。。。