![]() CATEGORIES: BiologyChemistryConstructionCultureEcologyEconomyElectronicsFinanceGeographyHistoryInformaticsLawMathematicsMechanicsMedicineOtherPedagogyPhilosophyPhysicsPolicyPsychologySociologySportTourism |
Comparison operators, and logical valuesComparison and Logical operators are used to test for true or false. Comparison Operators Comparison operators are used in logical statements to determine equality or difference between variables or values. Given that x=5, the table below explains the comparison operators:
Logical Operators : Logical operators are used to determine the logic between variables or values. Given that x=6 and y=3, the table below explains the logical operators:
And the logical values connected ofc with Boolean Data type. Boolean Data Type- E.g: true i.e. "true" is not equal to true, "true" will be considered as a string.
var a = true;
Example Code:
Bitwise Operators. Bitwise operators treat their operands as a sequence of 32 bits (zeros and ones), rather than as decimal, hexadecimal, or octalnumbers. For example, the decimal number nine has a binary representation of 1001. Bitwise operators perform their operations on such binary representations, but they return standard JavaScript numerical values. The following table summarizes JavaScript's bitwise operators:
35. Conditionals: if, '?' Conditional statements are used to perform different actions based on different conditions. Very often when you write code, you want to perform different actions for different decisions. You can use conditional statements in your code to do this. if statement - use this statement to execute some code only if a specified condition is true Use the if statement to execute some code only if a specified condition is true. Syntax if (condition) code to be executed if condition is true; The following example will output "Have a nice weekend!" if the current day is Friday: <html> <?php </body> Notice that there is no ..else.. in this syntax. The code is executed only if the specified condition is true.
Logical operators. The logical operation - in programming operation on a logical expressions (a Boolean) type, corresponding to some operations on the statements of the algebra of logic. As and expressions, logical expressions can take one of two veritable values are «true» or «false». Logical operations are used for production of complex logical expressions from more simple. In turn, the logical expressions are typically used as a condition for the sequence control program execution.
The logical operation And (conjunction, the operation of the logical multiplication). The action, which is determined by the operation And will, if fulfilled all affecting him factors (conditions). Action associated with the operation «And» can be written as follows: X = AB = A*B = A ^ B The logical operation OR (disjunction of the operation, the logical addition). The action, which is determined by the operation OR will happen, if executed at least one (any), which determine its condition. Action associated with the operation OR can be written as follows: X = A + B = A v B
The logical operation of the Exclusive OR. Operation Exclusive OR carries out the summation of the modulo two i.e. without account transfer in the senior category. Action associated with the operation Exclusive OR can be written as follows: X = A B. Operation identity. Operation identity determines the identity of the arguments. Action associated with the operation of identity can be written as follows: X = A B.
Cycles while, for While loop Syntax while (condition) Example The example below first sets a variable i to 1 ($i=1;). Then, the while loop will continue to run as long as i is less than, or equal to 5. i will increase by 1 each time the loop runs: <html> Output: The number is 1
The for loop is often the tool you will use when you want to create a loop. The for loop has the following syntax: for (statement 1; statement 2; statement 3) Statement 1 is executed before the loop (the code block) starts. Statement 2 defines the condition for running the loop (the code block). Statement 3 is executed each time after the loop (the code block) has been executed. Example for (var i=0; i<5; i++) Date: 2016-01-03; view: 1065
|