devicescript icon indicating copy to clipboard operation
devicescript copied to clipboard

string.toFixed

Open pelikhan opened this issue 1 year ago • 6 comments

tends to land in generated code.

   console.log(
        `Temperature: ${temperature.toFixed(2)}°C, Humidity: ${humidity.toFixed(
            2
        )}%`
    )
 

pelikhan avatar Mar 25 '23 02:03 pelikhan

Do you mean the toFixed function of Number? I think I can handle it.

JackTam1993 avatar Sep 14 '23 07:09 JackTam1993

I added a function called toFixed and I wrote a test case to test it. when I run the test function, it returned message: setting field 'toFixed' of a builtin frozen object.

JackTam1993 avatar Sep 14 '23 11:09 JackTam1993

Do you have a pull request we could look at?

pelikhan avatar Sep 14 '23 12:09 pelikhan

https://github.com/microsoft/devicescript/pull/621 here is the pull request. Thank you.

JackTam1993 avatar Sep 15 '23 03:09 JackTam1993

@mmoskal is number prototype special handled by the compiler?

pelikhan avatar Sep 15 '23 17:09 pelikhan

See comment on PR https://github.com/microsoft/devicescript/pull/621#issuecomment-1789310339

mmoskal avatar Nov 01 '23 16:11 mmoskal