inner object mthods return undefined?

Posted on
  • const typeStore = {
      b2_uint16_1p: arr => {
        let dv = new DataView(new Uint8Array(arr).buffer);
        let decim = dv.getUint16(0);
        return (decim / 10).toFixed(1);
      },
      b4_float32_: arr2 => {
        let dv = new DataView(new Uint8Array(arr2).buffer);
        let decim = dv.getFloat32(0);
        return decim;
      },
    }
    

    I invoke method like this:

    inter.prototype.interpret = function (dataTypeString, dataArr) {
      return typeStore[dataTypeString](dataArr);
    };
    
    let md=new Md;
    md.interpret[b4_float32_](99)
    
    {
      VERSION: "2v04.332",
      GIT_COMMIT: "57da2618",
      BOARD: "STM32F4DISCOVERY",
      FLASH: 1048576, RAM: 196608,
      SERIAL: "32005a00-0c513832-36393630",
      CONSOLE: "USB",
      MODULES: "Flash,Storage,hea" ... "S,WIZnet,neopixel",
      EXPTR: 536871244 }
    

    I can't invoke the second method, in this position, I just can only use the first method, the others just return UNDEFINED。

  • Please can you post up a full code example, as well as what version of Espruino you're using?

  • Mon 2020.03.16

    @Gordon, it appears we have a new user that may have reservations on posting code in an appropriate location as the board isn't an official supported one:

    Unfinished LoRa request under 'Electronics'

    http://forum.espruino.com/conversations/­343983/#comment15115450

    Unfinished SPI request under 'General'

    http://forum.espruino.com/conversations/­344239/#comment15125870

    STM32F4DISCOVERY

    As this isn't a tutorial for others, wouldn't a more prudent location be:

    Home >> Other Boards >> Other Boards
    Home >> Other Boards >> General

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

inner object mthods return undefined?

Posted by Avatar for user109783 @user109783

Actions