Skip to content

Instantly share code, notes, and snippets.

@CodeDrome
Created July 9, 2021 16:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CodeDrome/ff4dfc721800c252b1ad42083728fe02 to your computer and use it in GitHub Desktop.
Save CodeDrome/ff4dfc721800c252b1ad42083728fe02 to your computer and use it in GitHub Desktop.
mathjsunits04.js
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