JavaScript operator,arithmetic,assignment,Data Type,functions, objects

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Assignment operators

(1)Simple Assignment (=);assigns value form the right side operand to the left side operand (c=a+b will assign the value of a +b into c). (2)Add and Assignment (+=);it adds the right operand to the left operand and assigns the result to the left operand (c+=a is equivalent to c=c+a). (3)Subtract and Assignment (-=)it subtracts the right operand from the left operand and assigns the result to the left operand (c -=a is equivalent to c=c-a). (4)Multiply and Assignment (*=)it multiplies the right opeand with the left operand and assigns the result to the left operand (c *= a is equivalent to c =c * a). (5)Divide and Assignment (/=);if divides the right operand with the operand and assigns the result to the left operand(c/=a is equivalent to c =c/a). (6)Modules and Assignment (%=);it takes modulus using two operands and assigns the result to the left operand ( c%=a is equivalent to c= c%a) .

Arithmetic operators

Addition(+);adds two operands (a+b) Subtraction(-);subtracts second operand from first(a-b) Multiplication(*);multiply both operands Division(/);divide the numerator by the denominator (b/a) Modulus (%);outputs the remainder of an integer division (b%a remainder 0) Increment (++);increases an integer by one (a++) Decrement (--)decreases an integer value by one (a--)

operators types

Arithmetic, Comparison,logical(Relational),Assignment,and Conditional (ternary)

functions

allow a programmer to divide a big program into number of small and manageable functions. syntax for function; <script> <!-- funcition functionname (parameter-list) { statements } //--> </script>

objects

are composed of attributes. if an attribute contains a function, it is considered to be a method of the object, other wise the attribute is considered a property.

conparison operators

assume the variable a holds 10 and variable b holds 20 (1)Equal (==);checks if the two operands are equal or not, if yes, then the condition becomes true. (a==b) is not true. (2)Not Equal (!=);checks if the two operands are equal or not, if the values are not equal, then the condition becomes true (a!=b)is true. (3)Greater than (>);checks if the value of the left operand is greater than the value of the right operand, if yes, then condition becomes true (a>b) is not true. (4)Less than (<);checks if the value of the left operand is less than the value of the right operand, if yes, then the condition is true (a<b) is true. (5)Greater than or equal to (>=);checks if the value of the left operand id greater then or equal to the value of the rigth operand, if yes, then the condition becomes true (a>=b) is not true. (6)Less than or equal to (<=);checks if the value of the left operand is less than or equal to the value of the right operand, if yes,then the condition becomes true (a<=b) is true.

Logical operators

assume variable a holds 10 and variable b holds 20. (1)Logical AND(&&);if both the operands are non-zero, then the condition becomes true (a&&b)is true. (2)Logical OR (||);if any of the two operands are non-zero, then the condition becomes true (a || b) is true. (3) Logical NOT (!);reverses the logical state of its operand. if the condition is true, then the Logical NOT operator will make if false, ! (a&&b) is false.

Bitwise operators

assume variable a holds 2 and variable b holds 3. (1) Bitwise AND (&);it performs a Boolean AND operation on each bit of its integer arguments (a&b)is 2. (2)Bitwise OR (|);it performs a Boolean OR operation on each bit of its integer arguments (a | b)is 3. (3)Bitwise XOR (^);it performs a Boolean Exclucive OR operation on each bit of its integer arguments. Exclusive OR means that either operand one is true or operand two is true, but not both, (a^b)is 1. (4) Bitwise Not (~); is a unary operator and operates by reversing all the bits in the operand. (5) Left Shift (<<);it moves all the bits in its first operand to the left by the number of places specified in the second operand. new bits are filled with zeros. shift a value left by one is the equivalent to multiplying by 2,shifting two positions is equivalent to multiplying by 4, etc (a<<1)is 4. (6)Right shift (>>);binary Right Shift operator. the left operand's value is moved right by the number of bits specified by the right operand (a>>1) is 1. (7)Right shift with Zero (>>>);this operator is just like the >> operator, except that the bits shifted in on the left are always zero(a>>>1) is 1.

object properties

can be any of the three primitive data types, or an of the abstract data types such as another object. syntax for adding a property to an object is: objectName.objectProperty = propertyValue; example; the following code gets the document title using the "title" property of the document object; var str = document.title;

conditional operator

conditional (?:)if Condition is true? then value x : otherwise value y

object method

methods are the function that let the object do something or let something be done to it. a method is attached to an object and can be referenced by the (this) keyword. example of how to use the write() method; document.write ("This is test");


संबंधित स्टडी सेट्स

3.1 Conduct Crimes vs. Result Crimes

View Set

NCLEX PREP Leadership Management

View Set

Math Vocabulary Ch.10 Financial Literacy

View Set