L2 Features Object (1.2)
L2 Features Object (1.2)
Language (22519)
P R O G R A M : IN F O R M ATI O N T E C H N O L O G Y ( N B A
A C C R E D ITED )
S E M E S T ER : V
N A M E O F FA C U LTY: M S . Y O G I TA J O R E
Unit 1 :
Basics of JavaScript
Programming
(12 M)
P R O G R A M : IN F O R M ATI O N T E C H N O L O G Y ( N B A
A C C R E D ITED )
: V
N A M E O F FA C U LTY: M S . E M A I L :
y o g it a . k h a n d a g a le@v p t . e d u . in
Basics of JavaScript
Programming
1.1 Features of JavaScript
1.2 Object Name, Property, Method, Dot Syntax, Main Event
1.3 Values and Variables
1.4 Operators and Expressions
1.5 if statement , if…else. If…elseif, Nested if
1.6 switch… case statement
1.7 Loop statement
1.8 Querying and setting properties and Deleting properties,
Property Getters and Setters
Client side Scripting vs.
Server Side Scripting
Client-side scripting requires browsers to run the scripts on
the client machine but does not interact with the server
while processing the client-side scripts
Basic Works in the back end which Works at the front end and
could not be visible at the script are visible among the
client end. users.
</html>
Using “new” keyword
new keyword is used to create object.
Syntax: var objectname=new Object();
Example:
var person = new Object();
person.firstName = “Girija";
person.lastName = “Jore";
person.age = 10;
Example
<html>
<body>
<script>
var emp=new Object();
emp.id="VP-179";
emp.name="Yogita Jore";
emp.salary=50000;
document.write(emp.id+" "+emp.name+" "+emp.salary);
</script>
</body> OUTPUT VP-179 Yogita Jore 50000
</html>
By using Object Constructor
Here,
create you need
function
arguments. to
with
Each
can argument
be
current assigned
object value
byin the
using
this
The keyword.
this keyword refers
to the
Example:current object.
function person(firstName,
lastName, age)
{this. firstName =
firstName;
this. lastName =
lastName;
this. age = age;
}p=new person(“Girija”,”Jor
e”,10);
document.write(p.firstNam
e+"
e); "+p.lastName+" "+p.ag
Example
<html> <body>
<script>
function emp(id,name,salary)
{
this.id=id;
this.name=name;
this.salary=salary; OUTPUT VP-179 Yogita Jore 50000
}
e=new emp("VP-179","Yogita Jore",50000);
document.write(e.id+" "+e.name+" "+e.salary);
</script>
</body> </html>
Property
Properties are the values associated with a JavaScript object.
A JavaScript object is a collection of unordered properties.
Properties can usually be changed, added, and deleted, but some are
read only.
The syntax for accessing the property of an object is:
objectName.property // person.age
objectName["property"] // person["age"]
Ans: JavaScript
Ans : ID
Quiz
https://forms.office.com/Pages/ResponsePage.aspx?
id=QEUap70T20yz690UXwrJwIuVSIKHZ3RDo4EeJ2CYjgFUNVVKOElMTTBY
UVhFOVBOWVA4OUtPNlJINy4u