1 / 20

IF STATEMENT

IF STATEMENT. IF (CONDITION) { STATEMENTS 1; } [ELSE { STATEMENTS 2; } ]. SWITCH STATEMENT. SWITCH(EXPRESSION) { CASE LABEL : STATEMENTS; BREAK; CASE LABEL : STATEMENTS; BREAK; . . . DEFAULT : STATEMENTS; }. FOR LOOP. FOR ([INITIAL EXPRESSION]; [CONDITION];

kura
Download Presentation

IF STATEMENT

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. IF STATEMENT IF (CONDITION) { STATEMENTS 1; } [ELSE { STATEMENTS 2; } ]

  2. SWITCH STATEMENT SWITCH(EXPRESSION) { CASE LABEL : STATEMENTS; BREAK; CASE LABEL : STATEMENTS; BREAK; . . . DEFAULT : STATEMENTS; }

  3. FOR LOOP FOR ([INITIAL EXPRESSION]; [CONDITION]; [INCREMENTEXPRESSION];) { STATEMENTS; }

  4. WHILE LOOP WHILE (CONDITION) { STATEMENTS; }

  5. LABEL STATEMENTS LABEL: STATEMENTS CONTINUE CONTINUE [LABEL] BREAK BREAK [LABEL]

  6. FOR IN STATEMENT FOR ( VARIABLE IN OBJECT) { STATEMENTS }

  7. With statement With statement is used to avoid repeatedly specifying the object prefix syntax : with (object) { statements }

  8. ARGUMENTS ARRAY FUNCTIONNAME.ARGUMENTS[INDEX] EXAMPLE: ADDITION.ARGUMENTS[0]

  9. PREDEFINED FUNCTIONS • evel evaluates a string • isFinite evaluates a number whether finite or not • isNaN tests an argument is NOT A NUMBER • parseInt and parseFloat Returns int or float from string • Number and String Converts an object to Number/ String • escape Returns hexadecimal charecters in ISO • unescape Returns ASCII string for hexadecimal encoding

  10. Working with objects • CREATING NEW OBJECTS • OBJECTS AND PROPERTIES • PREDEFINED CORE OBJECTS LIKE ARRAY , MATH, DATE etc.

  11. CREATING NEW OBJECTS Objects can be created using Object Initializers The syntax is objectname = {property1:value1, property2:value2, … propertyn:valuen} Ex - > student = {sno:102, sna:”rama”, total:234}

  12. Objects using constructor Here 1 ) define the object with constructor 2) create object with new operator ex -> function employe(eno,ena,bsal) { this.eno = eno this.ena = ena this.bsal = bsal } var emp = new employe(200,”ramana”,3500) emp.eno = 100 emp.ena = “krishna” emp.bsal = 5000

  13. Defining properties for an object std.fee = 6500 Defining methods Object.methodname = functionname Deleting properties and objects delete std delete emp.bsal

  14. ARRAY OBJECT METHODS • CONCAT JOINS TWO ARRAYS & RETURNS NEW ARRAY • JOIN JOINS ALL ELEMENTS OF AN ARRAY INTO A STRING • POP REMOVES THE LAST ELEMENT OF AN ARRAY AND RETURNS THAT ELEMENT • PUSH ADDS ONE OR MORE ELEMENTS TO THE END OF AN ARRAY AND RETURNS THE LAST ELEMENT NO. ADDED

  15. ARRAY OBJECT METHODS • REVERSE TRANSPOSE THE ELEMENTS OF AN ARRAY • SHIFT REMOVES THE FIRST ELEMENT FROM AN ARRAY AND RETURNS THAT ELEMENT • SLICE EXTRACTS A SECTION OF AN ARRAY AND RETURNS A NEW ARRAY • SORT SORTS THE ARRAY • UNSHIFT ADDS ONE OR MORE ELEMENTS TO THE FRONT OF ARRAY

  16. DATE OBJECT METHODS getDate () returns date within month (1-31) getDay returns day within week (0-6) getHours() returns hour (0-23) getMinutes() returns minutes (0-59) getMonth() returns month (1-12) getSeconds() returns seconds (0-59) getTime() return number of milli seconds since 1/1/70 00:00:00 getYear() returns year getTimeZoneOffsetr() returns minutes offset • From gmt

  17. Date Object methods • setDate(value) sets date within month (1-31) • setHours(value) • setMinutes(value) • setSeconds(value) • setMonth(value) sets month within year(1-12) • setTime(value) sets number of milli seconds • setYear(value) sets number of years since 1900

  18. Date object parameters • Nothing creates an object with current date • “month dd,yyyy hh:mm:ss” creates an object with the specified date and time • yy,mm,dd creates an object with the specified date values • yy,mm,dd,hh,mm,ss creates an object with the specified date and time

  19. Math object methods • Abs(value) • acos(value) • asin(value) • atan(value) • ceil(value) • cos(value) • floor(value) • exp(value) • log(value) • max(value1,value2)

  20. Math object methods • Min(value1,value2) • pow(value1,value2) • random() • round(value) • sin(value) • sqrt(value) • tan(value)

More Related