Lab 8
JavaScript
Layout
Sorting
Arrays
Objects
01
02
03
Javascript Objects
Define a JavaScript object
Object name Object property Object value
Accessing Object
Objectname.property
Arrays
Array name
Creating array
Array item
Access Array Elements
The same output
for the both code
s
Add Elements
These statement
s for array eleme
nt adding
Methods
Search more methods
Iteration Methods
Comparing Function
If the result is negative a is sorted before b.
If the result is positive b is sorted before a.
If the result is 0 no changes are done with the sort order of the two values.
Object Array_example
Object Array_example
Original Object
After clicking Reverse
After clicking Sort
Evaluation:
• Define an Employees object
with the properties:
o Name
o Department
o StartingDate
o Salary
• Define at least 5 employees
in the object Employees
• Define a function that find th
e oldest employee to choos
e it as a CEO
• Increase the CEO salary by
20% of the original salary
• The Output should be like th
e image on the left
DD
HomeworkTry extra JS