0% found this document useful (0 votes)
7 views

FS JS DOC03 JS Objects and Classes asas

The document provides an overview of JavaScript ES6 features, focusing on Arrow Functions, Objects, and Classes. It includes practical use cases for calculating wages and hours worked, creating employee payroll data, and validating inputs using regular expressions. Additionally, it covers email validation and the structure of regex patterns for various applications.

Uploaded by

rarite5601
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

FS JS DOC03 JS Objects and Classes asas

The document provides an overview of JavaScript ES6 features, focusing on Arrow Functions, Objects, and Classes. It includes practical use cases for calculating wages and hours worked, creating employee payroll data, and validating inputs using regular expressions. Additionally, it covers email validation and the structure of regex patterns for various applications.

Uploaded by

rarite5601
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 39

Javascript

Programming
Constructs
Demonstrate JS ES6 Arrow
Functions, Objects, Classes,…
Arrow Function does what the normal JS Function
does or JS Functional Expression does
Arrow Function is similar to Lambda Function in
Java.
7. Arrow Function It can be inline or separately defined as functional
variable that can be passed as method parameters
It really simplifies the code and makes it look
elegant
For more refer link
Use the Daily Wage Map and
Daily Hour Map perform
following operations using
Arrow Functions
a. Calc total Wage and total hours worked
b. Show the full workings days, part working days and

UC 9 no working days
UC 9
Arrow
Functions
JS Supports creating of Objects Real
time. This is similar to JSON that we
are familiar with. Using JS Object
8. JS Objects you can
1. Define Field and Variable
assignment at the same time.
2. Define Function
Ability to store the Day,
Hours Worked and
Wage Earned in a single
object.
UC 10
UC 10
Object
Creation
Perform following Object
operations using Arrow
Functions
a. Calc total Wage and total hours worked
b. Show the full workings days using foreach
c. Show Part working days using Map by reducing to
String Array
UC 11 d. No working days only using Map function
UC 11 Object Operations using Arrow Functions
Classes are a template for creating
objects. They encapsulate data with
code to work on that data.

9. JS Classes
Ability to create
Employee Payroll Data
with id, name and
salary
UC 11
UC 11
Employee
Payroll Class
Ability to extend
Employee Payroll Data
to store gender and
start date
UC 12
UC 12
Extend
Employee
Payroll Class
Ability to check the name
starts with capital and has at
least 3 characters
- Use Regex Pattern
- Use Try Catch in case of Error
UC 13
UC 13
Use RegEx for
Name and
Throw Error
Ability to check the employee id
and salary are non zero positive
number, the gender is M or F and
date is not a future date
- Use Regex Pattern
- Use Try Catch in case of Error
UC 14
• Patterns or Regular expressions are
special characters which help
search data, matching complex
patterns. Regular expressions are
10. Patterns shortened as 'regexp' or 'regex’.
• Patterns used in Linux Terminal, or
Shell or Java are all similar and
many times can be used as is.
Basic Regex
Basic Regex Samples
mkdir pattern
Create a sample file
Basic Regex
Basic Regex Samples
Regex Explained
Regex Explained – Derive the Rules
Regex Explained – Patterns
Regex Program with Debug
The Postal Index Number
(PIN) or PIN Code is a 6
digit code of Post Office
numbering used
by India Post.
Create a regex pattern to
validate PIN code 400088
PIN Code UC 1
Restrict the PIN code from
taking alphabets or special
characters at the
beginning.
Check for A400088 – this
should fail
PIN Code UC 2
Restrict the PIN code from
taking alphabets or special
characters at the End.
Check for 400088B – this
should fail
PIN Code UC 3
Make sure 400 088 is also
valid along with 400088

PIN Code UC 4
Validate Email address with a
regex. The email consists of
minimum 3 and optional 2 more
parts with mandatory @ and .
abc.xyz@bridgelabz.co.in
Here abc, bridgelabz and co are
mandatory and the remaining 2
are optional
Email UC 1 To begin with lets validate the
mandatory part and start with abc
Ensure @ and validate the
mandatory 2nd part i.e.
bridgelabz

Email UC 2
Ensure “.” after bridgelabz
and validate the
mandatory 3rd part i.e. co

Email UC 3
Lets handle optional part
i.e. xyz in
abc.xyz@bridgelabz.co.in
NOTE: make sure only
following are valid special
characters _,+,-,.
proceeding to xyz
Email UC 4
Finally lets close the
expression with
supporting optional parts.
Note: Top Level Domains
(TLD) in the last part is the
optional country code and
its 2 characters only
Email UC 5
Sample Emails to Test
• A. Valid Emails B. Invalid Emails (TLD - Top Level Domains)
• 1. abc@yahoo.com, 1. abc – must contains “@” symbol
2. abc@.com.my – tld can not start with dot “.”
• 2. abc-100@yahoo.com, 3. abc123@gmail.a – “.a” is not a valid tld, last tld must contains at least two
• 3. abc.100@yahoo.com characters
4. abc123@.com – tld can not start with dot “.”
• 2. abc111@abc.com, 5. abc123@.com.com – tld can not start with dot “.”
• 4. abc-100@abc.net, 6. .abc@abc.com – email’s 1st character can not start with “.”
7. abc()*@gmail.com – email’s is only allow character, digit, underscore and dash
• 5. abc.100@abc.com.au
8. abc@%*.com – email’s tld is only allow character and digit
• 6. abc@1.com, 9. abc..2002@gmail.com – double dots “.” are not allow
10. abc.@gmail.com – email’s last character can not end with dot “.”
• 7. abc@gmail.com.com
11. abc@abc@gmail.com – double “@” is not allow
• 8. abc+100@gmail.com 12. abc@gmail.com.1a -email’s tld which has two characters can not contains digit
13. abc@gmail.com.aa.au - cannont have multiple email’s tld
References
• JS Fundamentals
• JS Complete Reference
• JS Tutorial
• JS Data Types
• Top 10 ES6 Features
• JS Function Expression
• JS Data Structures - Map
• JS Objects and use of Map, Reduce and Filter
• JavaScript ES6: Classes
Thank
You

You might also like