I have some JavaScript code:
<script type="text/javascript"> $(document).ready(function(){ $('#calcular').click(function() { var altura2 = ((($('#ddl_altura').attr("value"))/100)^2); var peso = $('#ddl_peso').attr("value"); var resultado = Math.round(parseFloat(peso / altura2)*100)/100; if (resultado > 0) { $('#resultado').html(resultado); $('#imc').show(); }; }); }); </script>
What does the ^
(caret) symbol mean in JavaScript?
The caret serves two different purposes. It is a special character that denotes “the beginning of a line” and it is a “not” operator inside of [] s. Matches any character that is not a vowel followed by any number of characters. Matches a vowel at the start of a line, followed by any number of characrters.
Carets are used in proofreading to signal where additional words or punctuation marks should be added to a line of text.
The bitwise XOR operator is indicated by a caret ( ^ ) and, of course, works directly on the binary form of numbers. Bitwise XOR is different from bitwise OR in that it returns 1 only when exactly one bit has a value of 1.
A caret is another name for a cursor. 2. Alternatively referred to as the circumflex, the caret is the symbol ( ^ ) above the 6 key on a standard United States qwerty keyboard. In mathematics, the caret represents an exponent, such as a square, cube, or another exponential power.
The ^
operator is the bitwise XOR operator. To square a value, use Math.pow
:
var altura2 = Math.pow($('#ddl_altura').attr("value")/100, 2);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With