Strategies for Landing an Oracle DBA Job as a Fresher
Â
Javascript
1.
2. Introduction
ď JavaScript is the most popular programming language in the
world.
ď JavaScript is the programming language of the Web.
ď Was designed to add interactivity to HTML pages.
ď All modern HTML pages are using JavaScript.
ď One of scripting language.
ď Supported by most the browsers
IE, Firefox, Chrome, Opera, Safari and Netscape Navigator.
3. Introduction
ď Embedded directly in HTML pages.
ď Java and JavaScript are two different languages.
ď Java can stand on its own.
ď JavaScript must be placed inside an HTML document to
function.
ď JavaScript is Case-sensitive.
4. Purpose
ď JavaScript Can Change HTML Content
ď JavaScript Can Change HTML Attributes
ď JavaScript Can Change HTML Styles (CSS)
ď JavaScript Can Validate Data
ď JavaScript Can display different pop-ups
5. Javascript in HTML
ď <script> tag is used to insert a JavaScript into an HTML
page.
Example:
<script>
document.getElementById("demo").innerHTML = "My First JavaScript";
</script>
ď Scripts in the body section
ď Scripts in the head section
ď Scripts in both the body section and head section
6. External JavaScript
ď External scripts are practical when the same code is used in
many different web pages.
ď External scripts cannot contain <script> tags.
ď Save it with a .js file extension.
â xxx.jsâ
ď Call script "src" attribute, from any of your html pages
<script src="xxx.js">
ď Advantages:
ďź It separates HTML and code.
ďź It makes HTML and JavaScript easier to read and maintain.
ďź Cached JavaScript files can speed up page loads.
7. JavaScript Output
ď Writing into an alert box, using window.alert().
<script> window.alert(5 + 6); </script>
ď Writing into the HTML output using document.write().
<script> document.write(5 + 6); </script>
ď Writing into an HTML element, using innerHTML.
<script>
document.getElementById("demo").innerHTML = 5+ 6;
</script>
ď Writing into the browser console, using console.log().
<script> console.log(5 + 6); </script>
8. JavaScript Comments
ď Single line comment: start the line with two slashes "//":
sum=a + b //calculating the sum
ď Multi line comment: "/*" and "*/"
/* This is a comment block. It contains several lines*/
9. JavaScript Variables
ď To store data values
ď Rules for Variable names:
ďźVariable names are case sensitive
ďźNames can contain letters, digits, underscores, and
dollar signs
ďźThey must begin with a letter ,the $ character or the
underscore character
ďźJavaScript keywords cannot be used as names
Declaration: var x;
var name;
Assign value to variable: x=5;
name=âFTDâ or âFTDâ;
10. JavaScript Variables
ď Declare & Assign variables :
var x=5;
var name=âFTDâ or âFTDâ;
ď One Statement, Many Variables :
var x=5, name=âFTDâ or âFTDâ;
ď Local variables
ď Global variables
ď Lifetime of JavaScript local & global Variables
11. JavaScript Data Types
ď JavaScript variables can hold many data types.
ď String, Number, Boolean, Array, Object and more.
ď Used to be able to operate on variables.
ď Examples:
var length = 16; // Number
var lastName = "Johnson"; // String
var cars = [âSkoda", "Volvo", "BMW"]; // Array
var x = {firstName:"John", lastName:"Doe"}; // Object
var z= true; //Boolean
12. JavaScript Data Types
ď If the one operand is a string, JavaScript will also treat the
other operand as a string.
var x = 16 + "Volvo";
ď JavaScript evaluates expressions from left to right.
var x = 16 + 4 + "Volvo";
var x = "Volvo" + 16 + 4;
ď JavaScript has dynamic types. The same variable can be used
as different types
var x = 5; // Now x is a Number
var x = "John"; // Now x is a String
13. JavaScript Operators
ď Arithmetic +, -, *, /, %, --, ++
ď Assignment =, -=, +=,*=, /=
ď Logical &&, ||, !
ď Comparison ==, !=, >, <, <=, >=,
Ternary operator(a<b)?A=10:A=5
â===âequal value and equal type
â!==ânot equal value or not equal type
above both compares both value and type, like belowâŚ
123=â123â
14. Functions
ď Function- is a block of code designed to perform a particular task and is
executed when
ďź When an event occurs (when a user clicks a button)
ďź When it is invoked (called) from JavaScript code
ďź Automatically (self invoked)
ď Define the code once, and use it many times
ď Same code many times with different arguments, to produce different results.
ď Defining function
function function_name(arguments)
{
statements;
}
Return statement
return(âtextâ);
15. Conditional stmts
ď In JavaScript we have three conditional statements:
if statement
if...else statement
if âŚelse if⌠else statement
Syntax:
if (condition1) {
block of code to be executed if condition1 is true
} else if (condition2) {
block of code to be executed if the condition1 is false and condition2 is true
} else {
block of code to be executed if the condition1 is false and condition2 is false
}
16. Switch stmts
ď Statement is used to perform different action based on different
conditions.
Syntax:
switch(expression) {
case n:
code n block
break;
case m:
code m block
break;
default:
default code block
}
17. Looping stmts
ď Loops can execute a block of code a number of times.
ď In JavaScript we have the following looping statements:
ďź while
Syntax:
while (condition) {
code block to be executed
}
18. Looping stmts
ďź do-while
Syntax:
do {
code block to be executed
}
while (condition);
ďź for
Syntax:
for (statement 1; statement 2; statement 3) {
code block to be executed
}
19. Arrays
ď Arrays are used to store multiple values in a single variable.
ď Array creation :
1. var team=new Array();
team[0]=âFTD";
team[1]=âMercury";
2. var team=new Array(âFTD",âMercury");
3. var team=[âftd",âMercuryâ];
ď Access an Array: we can access array elements by using name of
the array and index value.
ď Array methods : length, sort and etc âŚ
20. Events
ď Events are actions.
Examples of events:
1. A mouse click
2. Submitting an HTML form
3.A keystroke
ď <body> and <frameset> Events
ď Form Events
ď Image Events
ď Keyboard Events
ď Mouse Events
22. Popup Boxes
ď We can create three kinds of popup boxes:
ď Alert Box: information is displayed to the user.
Syntax: alert("sometext");
ď Confirm box: user to verify or accept something.
Syntax: confirm("sometext")
ď Prompt Box: user to input a value before entering a
page.
Syntax: prompt("sometext","defaultvalue")
23. Form validations
ď JavaScript can be used to validate input data in HTML
forms before sending off the content to a server.
ďź verify Required Fields using JavaScript
ďź verify Email using JavaScript
26. Assignments
ď Write a JavaScript program to get the website URL (loading
page)?
ď Write a JavaScript program to display the title of current page?
ď Write a JavaScript program to get the current date in
"dd/mm/yyyy" format?
ď Write a JavaScript program to find the area of a triangle where
lengths of the three of its sides are 5, 6, 7
ď Write a JavaScript program to calculate multiplication and
division of two numbers using functions(input from user).
27. Assignments
Assignment #1: Add field validations for HTML assignment #1 (Create an Employee Information Page)
The following fields should be mandatory, appropriate error message should display if the field is left blank or entered with
invalid data.
⢠Name field : Accept only alphabets and Max 20 characters.
⢠DOB (DD/MM/YYYY)
⢠What do you do Section
⢠Team Members text area
⢠Mailing Address
⢠Permanent Address
⢠Email ID field
Submit button : On clicking the âSubmitâ button
⢠Display message: âThank you. Your details are submitted successfullyâ, if valid data is entered in all the fields
⢠Display field level error message for each field, if invalid data is entered or filed is left blank.
Clear button: On clicking the âClearâ button
⢠Entered data should be cleared for all the fields.
28. Assignment #2: Add field validations for HTML assignment #2 (Create a webpage as below with
your information)
The following fields should be mandatory, appropriate error message should display if the field is left blank or entered
with invalid data.
⢠Name: Accept only alphabets and Max 40 characters.
⢠Email: Accept alphabet, special characters & numbers, characters should present before and after @ symbol,
end with .com/.org/.in
⢠Gender ( radio button)
⢠County( Drop down list)
⢠Get back to me via: Email , Phone, Personally ( Check boxes)
⢠Comments: Text area of a fixed size.
Submit button : On clicking the âSubmitâ button
⢠Display message: âThank you. Your details are submitted successfullyâ, if valid data is entered in all the fields
⢠Display field level error message for each field, if invalid data is entered or filed is left blank.