Depending on the type of value in a variable we can apply various different operators to them.
For example with numbers we can use arithmetic operators to add subtract divide multiply and so on.
For example here we've got two variables with integer values.
We can add a number to one of the variables we can multiply them together for example.
And so on using basic mathematical operations you are no doubt familiar with when we run this code.
We see the result of the addition and multiplication.
We just did some maths with integer values.
But we can also do this with floats.
Here we have some more variables but this time one of them is a float value.
If we multiply them together
we get this result.
Note how the result is a float.
Even though we multiplied a float by an integer in some languages.
This would give an error but p p is very forgiving and with evaluates the integer value used in the
calculation as a float after Mattingly.
There are also operators that we can use on string values.
For example if we have two strings like this we can can Catton them together using the dot operator.
If we view this in the browser we see the strings join together.
You can use the operator more than once in a single instruction.
If you like.
So let's have a space between these two values.
And now when we run the code we have a space between the two strings.
What do you think will happen when you try and do something like this here.
We're multiplying a string by an integer and then assigning the results of multiplying these two together
back to the first variable which contains a string.
Then we're printing out the result of this variable when we run this code.
We get an integer result so this is what is contained in this variable now.
P.
P has changed the type of this variable from a string to an integer.
This is known as type conversion type juggling.
This is done automatically by P.
Whenever it's necessary.
You can perform an explicit type conversion if you like which is known as casting.
However it's not very common to have to do that.
So we won't worry about that just yet.
For boolean values we have all logical operators we can use these to change the value of a boolean variable
or combine different boolean variables together.
For example here we have a couple of billion variables.
If we print out the value of the first one we get true.
We can negate this boolean value using the not operator which is an exclamation mark in front of the
variable like this.
This basically means true is change to false and false is changed to true in the browser we now get
to value are false.
We can also combine boolean variables using and are are exclusive are.
For example if we print out the value of is editor or is admen.
The result of this is true.
This is because true are false is true.
If we change this to and
then in the browser we get the false.
This is because true and false results in false.
The results of combining various boolean values using these operators now shown here in the documentation.