Presentation is loading. Please wait.

Presentation is loading. Please wait.

JavaScript Non Primitive Datatype

Similar presentations


Presentation on theme: "JavaScript Non Primitive Datatype"— Presentation transcript:

1 JavaScript Non Primitive Datatype
Object Array RegExp 12/1/2017 Internet programming UNIT III

2 Internet programming UNIT III
object State and behavior Object-based language No need to create a class – directly object is created Ways of creating objects Object literal Instance of object directly (new) Object constructor 12/1/2017 Internet programming UNIT III

3 Internet programming UNIT III
object literal instance of Object <script> emp={id:102,name:"Shyam Kumar",salary:40000} document.write(emp.id+" "+emp.name+" "+emp.salary); </script> <script> var emp=new Object(); emp.id=101; emp.name="Ravi Malik"; emp.salary=50000; document.write(emp.id+" "+emp.name+" "+emp.salary); </script> 12/1/2017 Internet programming UNIT III

4 Internet programming UNIT III
Object constructor <script> function emp(id,name,salary){ this.id=id; this.name=name; this.salary=salary; } e=new emp(103,"Vimal Jaiswal",30000); document.write(e.id+" "+e.name+" "+e.salary); </script> 12/1/2017 Internet programming UNIT III

5 Java Script Date object
Timer – web page Date Constructors – Date object Date() Date(milliseconds) Date (dateString) Date(year,month,day,hours,minutes,seconds,milliseconds) JavaScript Date Methods getFullYear() getMonth() getDate() getDay() getHours() getMinutes() getSeconds() 12/1/2017 Internet programming UNIT III

6 Internet programming UNIT III
Example <html> <body> <p id="dynamic"> </p> <script> var a=new Date(); document.getElementById("dynamic").innerHTML=a; </script> </body> </html> 12/1/2017 Internet programming UNIT III

7 Internet programming UNIT III
String Regular Expression Exception handling 12/1/2017 Internet programming UNIT III


Download ppt "JavaScript Non Primitive Datatype"

Similar presentations


Ads by Google