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;
      VERSION: "2v04.332",
      GIT_COMMIT: "57da2618",
      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'­343983/#comment15115450

    Unfinished SPI request under 'General'­344239/#comment15125870


    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

inner object mthods return undefined?

Posted by Avatar for user109783 @user109783