Hi, I provide training in SAP UI5. Also feel free to checkout my new web page https://saptechblog.com
Javascript

Operators

We have different types of operators supported in our programming languages. The most categories of operators are:

1. Arithmetic operator

2. Comparison operator

3. Logical operator

4. Assignment operator

5. Conditional operators

Arithmetic operators:

clip_image002

Program:

Assume that variable A holds the value 10 and Variable B holds value 20:

clip_image004

Here while writing the output I have concatenated the variable to the text using + operator and written the output.

e.g document.write(“Literals are passed within quotations ” + variable );

Note: We don’t have the increment or decrement operator in ABAP, we normally achieve it through a = a + 1;

Assignment operators:

clip_image006

Program Code:

clip_image008

Note: We don’t have any of the assignment operators other than equals to ABAP. All other forms are achieved as in example. e.g a += b; is written as a = a + b.

Comparison operator:

clip_image010

All these operators are similar in usage as with ABAP, except that we don’t use double equal to check the equality between two variable and not equal to operator differs from the normal usage.

Equal to operator:

In javascript, if (a == b);

In ABAP, if a = b.

Not equal to operator:

In Javascript, if (a!= b);

In ABAP if a<>b.

Logical Operators:

clip_image012

We don’t have any of these operators in usage in our ABAP program, Instead we have keyword “AND” for “&&”, “OR” for “||” and “NOT” for “!”.

In javascript, instead of keywords we need to use the symbolic representation. Remaining usage of these operators remains the same as with that of ABAP.

Bitwise Operators:

Bitwise operators are bit advance and will be discussed in later chapters if usage of this operator is required.

clip_image014

Conditional Operators:

The condition operator checks condition and assign value to the variables. If the condition is true then value after question mark is assigned, if condition is false value after colon is assigned.

clip_image016

If the value of x is greater than 18 then old enough will be the value assigned to variable votable.

Note: This operator is similar to that of if…else.. condition in ABAP.

About Arun

1 Comments:

  1. Appreciation for really being thoughtful and also for deciding on certain marvelous guides most people really want to be aware of.

    AWS Training in Chennai

    ReplyDelete

Powered by Blogger.