Workaround for not jet implemented String.padStart/padEnd #1442
Replies: 7 comments
-
Posted at 2020-09-07 by AkosLukacs Almost there, but this blows up of the len is smaller than the length of the string without padding. A small modification solves it (
MDN usually has polyfills or in this case, a link to polyfills: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padStart |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-09-07 by @MaBecker Hmm, isn’t a negative value : false? Edit: just tested - it is not ........ So many thanks for your input! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-09-08 by AkosLukacs Yepp, JS if full of interesting things, some help: Btw
Obligatory talk/video: https://www.destroyallsoftware.com/talks/wat |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-09-08 by @MaBecker WAT Video is super funny - It is a must - wat a cool guy! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-09-08 by @fanoush
gives different results which is interesting because
btw tried stuff from wat video in node.js and
which is not very sophisticated answer, NaN answer was much wiser :-) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-09-14 by @gfwilliams Interesting - thanks! If padStart/padEnd really are that simple then they could probably be added to the firmware. It's one of those things that is pretty commonly used |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-10-08 by @gfwilliams Just added espruino/Espruino@05c89c9 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2020-09-07 by @MaBecker
Had the need to fill a string with '0' at the end.
Beta Was this translation helpful? Give feedback.
All reactions