Created
July 9, 2021 16:42
-
-
Save CodeDrome/ff4dfc721800c252b1ad42083728fe02 to your computer and use it in GitHub Desktop.
mathjsunits04.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function valueProperty() | |
{ | |
const centimetres = math.unit(50, 'cm'); | |
output(`centimetres: ${centimetres}`); | |
output(`centimetres.value: ${centimetres.value}`); | |
// setting value will give a result in metres | |
// despite the unit being cm | |
centimetres.value = 150; | |
output(`centimetres.value = 150: ${centimetres}`); // metres | |
output("VALUE IS NOW 150 m, not cm WHICH IS PROBABLY UNINTENDED"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment