Programming Examples

Are you a Programmer or Application Developer or a DBA? Take a cup of coffee, sit back and spend few minutes here :)


JavaScript is a Type-less scripting language used windely in the web programming world.

JavaScript 002 – Calculation via Expression

JavaScript Expression Evaluation

In JavaScript, you can perform arithmetic by forming the expressions. When making the expression, you can use binary operators like addition (+), subtraction (-), multiplication (*) and division (/). We call them as a Binary Operator as it operates on two variants. Now look at the expression below:

10 – 4 * 2

You may expect the result is 12. But the result is 2. Because here Operator Precedence comes into picture. The operator * and / play higher priority than the + and – operators. In the above expression, the binary operation * is figured out on the operands 4, 2. Then the binary operation minus is done on the operand 10 and 8 giving up the result as 2. In the above expression, we used only the constant values. But one can use the variables also as an operand.

Continue Reading →

JavaScript 001 – Declare Variable

First Java Script - Declare Variable

In JavaScript, you can declare a variable using the var keyword. This tells the system to reserve some memory for future use. After declaring the variable, we can store a value in it. For example:

var MyVar;
Myvar = 12;

In the above snippet, we declare a variable called MyVar using the keyword var. In the next line, we store a value of 12 into the variable MyVar. The = sign denotes the assignment. Means. It tells value 12 is assigned to the variable MyVar. Note, JavaScript is case sensitive and when you read the back the value you have to use the same variable name with the same case.

Continue Reading →