980qc

My Blogger TricksAll Blogger TricksAll Blogging Tips

Contact me

hackercrackerblog@gmail.com
Powered by Blogger.

VOTE FOR MYBLOG

Subscribe to sms alerts

CLICK Shuffle Icon below to get a random post

Social Icons

Featured Posts

SCAN THIS QR CODE TO DOWNLOAD BLOG'S ANDRIOD APP OR CLICK DOWNLOAD TO DOWNLOAD TO YOUR PC



pop

My Blogger TricksAll Blogger TricksTechtunes

Join and Earn

Search This Blog

NEW BLOG

addthis

Video Of Day

Text Widget

Followers

Social Icons

Horizontal Post Sample

Popular Posts

Social Icons

Home » , » The basic operations in javascript

The basic operations in javascript

 The basic operations in javascript


This post is to explain about fundamental operations in JavaScript. With this basic arithmetic operations can be combined or changed data in the Javascript code. There are many operations (also known as operator) is used in JavaScript.



1. The arithmetic

Very common and common, except for arithmetic of multiplying and dividing that any student who knows. The variable and its value is the number.
  • = (Equal sign) - ie, (x = 8)
  • + (Plus sign) - ie, (x = 7 +8)
  • - (Minus) - ie, (x = 7-8)
  • * (Multiplication) - ie, (x = 7 * 8)
  • / (Breaks) - ie, (x = 7/8)
Besides the simple math on it also uses the following arithmetic for programming.
  • Modulo (%) - Do not be mistaken with a percent sign, here is balance calculations take the division. Consider the following example shows the remainder of the division is 8 3 2 
    For example: 
    8% 3 result 2 
    10% 2 result 0
  • Increment (+ +) - This operation adds an extra base value units. Often used as an abbreviation allowed in programming. For example, if we have the variable 'i' can be increased by an additional unit of the variable i by writing i + + instead of to i = i +1. 
    For example: 
    x = 7; 
    x + +; 
    result is x = 8
  • Decrement (-) - Subtract the original value of 1 unit. If we have variable 'i' can be used to write i - instead of i = i-1. 
    For example: 
    x = 7; 
    x -; 
    result is x = 6

2. Assignments

Assignments are one of the basic operations of JavaScript. Assignments used to assign a value to a variable. In the assignment expression, the right operand is assigned the value of the operand to the left of the equal sign (=)
Operator Operator Example Example Same as Same as
= = x = y x = y x = y x = y
+= + = x += y x + = y x = x+y x = x + y
-= - = x -= y x - y = x = xy x = xy
*= * = x *= y x * = y x = x*y x = x * y
/= / = x /= y x / = y x = x/y x = x / y
%= % = x %= y x% = y x = x%y x = x% y

3. Comparison Operands

A mathematical comparison returns a boolean value is TRUE (true) or FALSE (false). By comparing the two operands mark comparison (==) Javascript will give us the answer depends on the value of the operand. View the table below to understand math better

Operator Operator Meaning Meaning Example Example
== == Identical Identical 3 == 8 result FALSE 3 8 result == FALSE
!= ! = Different Different 3 != 8 result TRUE 3! = 8 result TRUE
> > Bigger Bigger 3 > 8 result FALSE 3> 8 result FALSE
< < Smaller Smaller 3 < 8 result TRUE 3 <8 result TRUE
>= > = Bigger or identical Bigger or identical 3 >= 8 result FALSE 3> = 8 result FALSE
<= <= Smaller or identical Smaller or identical 3 <= 8 result TRUE 3 <= 8 result TRUE 

4. Logical operations (booleans)

A mathematical logic compares two expressions and returns a value of TRUE (true) or FALSE (false).
  • && - AND - AND operator compares two expressions and returns TRUE if both values ​​are true and vice versa will return FALSE.
    • x = 5 
      y = 8 
      x <7 amp="" y=""> 3 
      (Returns TRUE)
  • | | - OR - OR operation compares two expressions and returns TRUE if either the right and vice versa returns FALSE.
    • x = 5 
      y = 8 
      x> 7 | | y <3 b=""> 
      (Returns FALSE)
  • ! - NOT - NOT A mathematical, math negative returns TRUE if the expression is false, and vice versa if true, the expression returns FALSE.
    • x = 5 
      y = 8 
      ! (X == y) 
      (Returns TRUE because the value of 'x' else 'y')

5. Operands used for string

Addition operation is used to combine two variables with text values ​​together
  • t1 = "Have a good" 
    t2 = "life." 
    t3 = t1 + t2 
    (The return value of the variable t3 is "Have a good life.")
Item Reviewed: The basic operations in javascript Description: Rating: 5 Reviewed By: sumanth s

0 comments:

Post a Comment

ask about any software doubts or any software updates,inform about broken links

.

Label 1