SlideShare a Scribd company logo
WEB
FRAMEWORKS
1Monica Deshmane(H.V.Desai College,Pune)
Syllabus : What we learn?
See link - https://prezi.com/view/NNmyKQS4eeL9lz89bQyz/
 Javascript basics
 Introduction to Node JS (framework to run JS without browser anywhere)
• Node JS Modules
• NPM
• Web Server
• File system
• Events
• Databases
• Express JS
 Introduction to DJango (quick & easy to develop app with minimum code)
 Setup
 URL pattern
 Forms &Validation
Monica Deshmane(H.V.Desai College,Pune) 2
chap 1 Java Script Basics
1.1 Java Script data types
1.2 Variables, Functions, Events,
Regular Expressions
1.3 Array and Objects in Java Script
1.4 Java Script HTML DOM
1.5 Promises and Callbacks
Introduction
JavaScript is the scripting language for HTML
and understood by the Web.
JavaScript is easy to learn.
JavaScript is made up of the 3 languages :
1. HTML for look & Feel.
2. CSS to specify the layout or style.
3. JavaScript for Event Handling.
The <script> Tag
Ex. How to write JS?
<script type="text/javascript">
var i = 10;
if (i < 5) {
// some code
}
</script>
The <script> Tag
Attributes of <script>
1. async- script is executed asynchronously (only
for external scripts)
2. charset –charset Specifies the character
encoding format.
3. defer -Specifies that script is executed when
the page has finished parsing
4. src - Specifies the URL of an external script file
5. type - Specifies the media type of the script
6. Lang- To specify which language to use.
The <script> Tag in
< Body>
Script gets executed automatcally when program runs
or we can call by function call.
<html>
<body>
<p id=“p1">A Paragraph</p>
<Input type="button" onclick="myFunction()“
value=“change”>
<script>
function myFunction() {
document.getElementById(“p1").innerHTML =
"Paragraph changed.";
}
</script>
</body>
</html>
The <script> Tag in
< Head> The function must be invoked (called) when event
occurs .
Ex. button is clicked:
<html>
<head> <script>
function myFunction() {
document.getElementById(“p1").innerHTML
= "Paragraph changed.";
}
</script></head>
<body>
<p id=“p1">A Paragraph</p>
<Input type="button" onclick="myFunction()">Try it</Input>
</body></html>
https://www.w3schools.com/js/tryit.asp?filename=tryjs_intro_inner_html
Java Script data types
1) String
var Name = “parth"; // String
2) Number
var length = 36; // Number
3) Boolean
Booleans can only have two values: true or false.
4) Undefined
var x = 5;
var y = 5;
(x == y) // Returns true
typeof (3) // Returns "number" to return data type of variable
typeof undefined // undefined
monica Deshmane(H.V.Desai College,Pune)
1) Primitaive data type
Java Script data types
1) Function
function myFunction() { }
2) Object
var x = {firstName:"John", lastName:“Ray"}; // Object
3) Array
var cars = [“suzuki", "VagonR", "BMW"]; //array
var person = null; //null
//diffrence between null & undefined
1) typeof undefined // undefined
typeof null // object
2) null === undefined // false
null == undefined // true
monica Deshmane(H.V.Desai College,Pune)
2)complex data types
JS Types:Revise
You can divide JavaScript types into 2 groups
1) primitive - are number, Boolean, string, null
2) complex -are array ,functions ,and objects
//primitive
Var A=5;
Var B=A;
B=6;
A; //5
B; //6
//complex or reference types
Var A=[2,3];
Var B=A;
B[0]=3;
A[0]; //3
B[0]; //3
JavaScript variables are used for storing data values.
Same rules of variables in java are followed.
var x = 5;
var y = 6;
var z = x + y;
also learn-
local variables,
global variables,
static variables
Java Script variables
monica Deshmane(H.V.Desai College,Pune)
A JavaScript function is a block of code to perform a
particular task.
executed when someone invokes / calls it.
Syntax:-
function name(para1, para2, para3)
{
// code to be executed
}
Java Script Functions
monica Deshmane(H.V.Desai College,Pune)
Function Invocation i.e call needed.
Return value- Functions often compute a return value.
The return value is "returned" back to the "caller".
Example-
var x = myFunction(10, 3);
// Function is called, return value will assigned to x
function myFunction(a, b)
{
return a * b; // Function returns the product of a and b
}
Java Script Functions
monica Deshmane(H.V.Desai College,Pune)
var f=function f()
{
typeof f== “function”; //true
window==this; //true
//as this is global object
}
.call & .apply method-To change reference of this to any
other object when calling function.
function a() {this.a==‘b’; //true}
funcation a(b,c){
b==‘first’; //true
c==‘second’; //true
}
a.call((a:’b’),’first’,’second’);
//call takes list of parameters to pass function
a.apply({a:’b’},[’first’,’second’]);
//apply takes array of parameters to pass function
monica
Deshmane(H.V.Desai
College,Pune)
Some concepts about function..
Java Script Events
Event Description
onChange An HTML element has been changed
onClick The user clicks an HTML element / control
onMouseOver The user moves the mouse over an HTML element
onMouseOut The user moves the mouse away from an HTML
element
onKeydown The hits pushes a keyboard key
onLoad After loading the page
onFocus When perticular control is hilighted
See demo online
monica Deshmane(H.V.Desai College,Pune)
•e.g.
•<button onclick="displayDate()“>The time is?</button>
<body onload=“display()”>….</body>
<input type=text name=“txt” onmouseover = “display()”>
<input type=text name=“txt” onFocus = “display()”>
Examples of events
Regular Expressions( RE)
monica Deshmane(H.V.Desai College,Pune)
A regular expression is a sequence of
characters that forms a pattern.
The pattern can be used for
1)search
2)replace
3)Match
A regular expression can be made by a
single character, or a more complicated
/mixed patterns.
Patterns
Character classes
[:alum:] Alphanumeric characters [0-9a-zA-Z]
[:alpha:] Alphabetic characters [a-zA-Z]
[:blank:] space and tab [ t]
[:digit:] Digits [0-9]
[:lower:] Lower case letters [a-z]
[:upper:] Uppercase letters [A-Z]
[:xdigit:] Hexadecimal digit [0-9a-fA-F]
range of characters ex. [‘aeiou’]
Patterns continue…
? 0 or 1
* 0 or more
+ 1 or more
{n} Exactly n times
{n,m} Atleast n, no more than m
times
{n,} Atleast n times
n newline
t tab
^ beginning
$ end
Using String Methods
monica Deshmane(H.V.Desai College,Pune)
the two string methods used for RE are search() and replace().
1. The search() method uses an expression to search for a match,
and returns the position of the match.
var pos = str.search(“/this/”);
2. The replace() method returns a modified string where the pattern
is replaced.
var txt = str.replace(“/is/”, “this");
3. match() used to match pattern
“hi234”.match(/^ (a-z) +(d{3})$/)
4. exec() -Syntax- pattern.exec(string);
The exec() method returns the matched text if it finds a match,
otherwise it returns null.
“/(hey|ho)/”.exec('h') //h
Array in Java Script
monica Deshmane(H.V.Desai College,Pune)
1. Array creation
• var arr1 = new Array(); OR
• var arr2 = [ ];
arr2.push(1);
arr2.push(2); //[1,2]
arr1.sort();
• var arr3 = [ ‘mat', 'rat', 'bat' ];
2. Length
arr2.length;
console.log(arr2);
3. To delete element from array
arr3.splice(2, 2);
arr.pop(); //see demo on JS.do
Array splice in Java Script
monica Deshmane(H.V.Desai College,Pune)
<script>
var lang = ["HTML", "CSS", "JS", "Bootstrap"];
document.write(lang + "<br>");
var removed = lang.splice(2, 1, 'PHP', ‘python')
document.write(lang + "<br>");
// HTML,CSS,JS,Bootstrap
document.write(removed + "<br>");
// HTML,CSS,PHP,python,Bootstrap
// No Removing only Insertion from 2nd index from the ending
lang.splice(-2, 0, 'React') // JS
document.write(lang)
// HTML,CSS,PHP,React,python,Bootstrap
</script>
Array continue…
monica Deshmane(H.V.Desai College,Pune)
Array is like u so before the typeof operator will
return “object” for arrays more times however you
want to check that array is actually an array.
Array.isArray returns true for arrays and False for
any other values.
Array.isArray( new array) // true
Array.isArray( [ ] ) // true
Array.isArray( null) // false
Array.isArray(arguments ) //false
Array continue…
monica Deshmane(H.V.Desai College,Pune)
See –tutorials point javascript arrays
array methods
• to loop over an array you can use for each (Similar to jquery $.each)
[1,2,3].foreach(function value)
{ console.log (value ); }
•To filter elements out of array you can use filter (similar two jQuery
grep)
[1,2,3].foreach(function value)
{ return value < 3; } //will return [ 1, 2]
•to change value of of each item you can use map (similar to Jquery
map)
[ 5,10 ,15].map function (value)
{ return value*2; } // will return [10 ,20 ,30]
• also available but less commonly used are the methods-
reduce , reduceRight and lastIndexOf.
Array continue…
monica Deshmane(H.V.Desai College,Pune)
•reduceRight:-Subtract the numbers in the array, starting from the right:
<script>
var numberarr= [175, 50, 25];
document.getElementById(“p1").innerHTML =
numberarr.reduceRight(myFunc);
function myFunc(total, num) {
return total - num;
}
•Reduce-from left to right
•lastIndexOf-
const animals = ['Dog', 'Tiger', 'Penguin','Dog'];
console.log(animals.lastIndexOf('Dog'));// expected output: 3
console.log(animals.lastIndexOf('Tiger'));// expected output: 1
•Object Creation
var obj1 = new Object();
var obj2 = { };
var subject = { first_name: "HTML", last_name: "CSS“ ,
reference: 320 ,website: "java2s.com" };
•add a new property
subject.name= "brown"; OR
subject["name"] = "brown";
•To delete a new property
delete subject.name;
•To get all keys from object
var obj={a:’aaa’, b:’bbb’ ,c:’ccc’};
Object.keys(obj); //[‘a’ ,’b’, ‘c’]
Objects in Java Script
HTML DOM
The HTML DOM is a standard object model and
programming interface for HTML.
It contains -The HTML elements as objects
-The properties of all HTML elements
-The methods to access all HTML elements
-The events for all HTML elements
DOM CSS- The HTML DOM allows JavaScript to change the
style of HTML elements.
DOM Animation- create HTML animations using JavaScript
DOM Events- allows JavaScript to react to HTML events by event
handlers & event Listeners.
HTML DOM elements are treated as nodes ,in which elements
can be added by createElement() or appendChild()
& deleted nodes using remove() or removeChild().
HTML DOM continue…
Promises & callback
- The promises in Javascript are just that, promises it means that we will do
everything possible to achieve the expected result. But, we also know that a
promise cannot always be fulfilled for some reason.
Just as a promise is in real life, it is in Javascript, represented in another way.
Promises
Example
let promise = new Promise(function(resolve, reject)
{ // task to accomplish your promise
if(/* everything turned out fine */)
{ resolve('Stuff worked') }
else { // for some reason the promise doesn't fulfilled
reject(new Error('it broke'))
}
});
Promises have three unique states:
1. Pending: asynchronous operation has not been completed
yet.
2. Fulfilled: operation has completed and returns a value.
3. Rejected: The asynchronous operation fails and the
reason why it failed is indicated.
Callback function
will be executed when an asynchronous operation has been
completed.
A callback is passed as an argument to an asynchronous operation.
Normally, this is passed as the last argument of the function.
When a function simply accepts another function as an argument, this
contained function is known as a callback function.
Callback functions are written like :
function sayHello()
{ console.log('Hello everyone');}
setTimeout( sayHello( ), 3000);
What we did in the above example was, first to define a function that
prints a message to the console. After that, we use a timer
called setTimeout (this timer is a native Javascript function). This timer is
an asynchronous operation that executes the callback after a certain time.
In this example, after 3000ms (3 seconds) will be executed the
sayHello() function.
Difference between callback and promises
1. promises are easy for running asynchronous
tasks to feel like synchronous and also provide
catching mechanism which are not in callbacks.
2. Promises are built over callbacks.
3. Promises are a very mighty abstraction, allow
clean and better code with less errors.
4. In promises, we attach callbacks on the returned
promise object. For callback approach, we
normally just pass a callback into a function that
would then get called upon completion in order to
get the result of something.
.
34Monica Deshmane(H.V.Desai College,Pune)

More Related Content

What's hot

Advanced task management with Celery
Advanced task management with CeleryAdvanced task management with Celery
Advanced task management with Celery
Mahendra M
 
SenchaCon 2016: Modernizing the Ext JS Class System - Don Griffin
SenchaCon 2016: Modernizing the Ext JS Class System - Don GriffinSenchaCon 2016: Modernizing the Ext JS Class System - Don Griffin
SenchaCon 2016: Modernizing the Ext JS Class System - Don Griffin
Sencha
 
Tech talk
Tech talkTech talk
Tech talk
Preeti Patwa
 
Chat Room System using Java Swing
Chat Room System using Java SwingChat Room System using Java Swing
Chat Room System using Java Swing
Tejas Garodia
 
JavaScript 101
JavaScript 101JavaScript 101
JavaScript 101
ygv2000
 
Jsp/Servlet
Jsp/ServletJsp/Servlet
Jsp/Servlet
Sunil OS
 
Performance Optimization and JavaScript Best Practices
Performance Optimization and JavaScript Best PracticesPerformance Optimization and JavaScript Best Practices
Performance Optimization and JavaScript Best Practices
Doris Chen
 
ExtJs Basic Part-1
ExtJs Basic Part-1ExtJs Basic Part-1
ExtJs Basic Part-1
Mindfire Solutions
 
Utopia Kindgoms scaling case: From 4 to 50K users
Utopia Kindgoms scaling case: From 4 to 50K usersUtopia Kindgoms scaling case: From 4 to 50K users
Utopia Kindgoms scaling case: From 4 to 50K users
Jaime Buelta
 
Node Boot Camp
Node Boot CampNode Boot Camp
Node Boot Camp
Troy Miles
 
Celery - A Distributed Task Queue
Celery - A Distributed Task QueueCelery - A Distributed Task Queue
Celery - A Distributed Task Queue
Duy Do
 
Mongoose: MongoDB object modelling for Node.js
Mongoose: MongoDB object modelling for Node.jsMongoose: MongoDB object modelling for Node.js
Mongoose: MongoDB object modelling for Node.js
Yuriy Bogomolov
 
iOS 2 - The practical Stuff
iOS 2 - The practical StuffiOS 2 - The practical Stuff
iOS 2 - The practical Stuff
Petr Dvorak
 
JavaScript and UI Architecture Best Practices
JavaScript and UI Architecture Best PracticesJavaScript and UI Architecture Best Practices
JavaScript and UI Architecture Best Practices
Siarhei Barysiuk
 
Ten useful JavaScript tips & best practices
Ten useful JavaScript tips & best practicesTen useful JavaScript tips & best practices
Ten useful JavaScript tips & best practices
Ankit Rastogi
 
Codegeneration With Xtend
Codegeneration With XtendCodegeneration With Xtend
Codegeneration With Xtend
Sven Efftinge
 
Functionnal view modelling
Functionnal view modelling Functionnal view modelling
Functionnal view modelling
Hugo Saynac
 
J Query The Write Less Do More Javascript Library
J Query   The Write Less Do More Javascript LibraryJ Query   The Write Less Do More Javascript Library
J Query The Write Less Do More Javascript Library
rsnarayanan
 
Javascript and Jquery Best practices
Javascript and Jquery Best practicesJavascript and Jquery Best practices
Javascript and Jquery Best practices
Sultan Khan
 
Workshop 8: Templating: Handlebars, DustJS
Workshop 8: Templating: Handlebars, DustJSWorkshop 8: Templating: Handlebars, DustJS
Workshop 8: Templating: Handlebars, DustJS
Visual Engineering
 

What's hot (20)

Advanced task management with Celery
Advanced task management with CeleryAdvanced task management with Celery
Advanced task management with Celery
 
SenchaCon 2016: Modernizing the Ext JS Class System - Don Griffin
SenchaCon 2016: Modernizing the Ext JS Class System - Don GriffinSenchaCon 2016: Modernizing the Ext JS Class System - Don Griffin
SenchaCon 2016: Modernizing the Ext JS Class System - Don Griffin
 
Tech talk
Tech talkTech talk
Tech talk
 
Chat Room System using Java Swing
Chat Room System using Java SwingChat Room System using Java Swing
Chat Room System using Java Swing
 
JavaScript 101
JavaScript 101JavaScript 101
JavaScript 101
 
Jsp/Servlet
Jsp/ServletJsp/Servlet
Jsp/Servlet
 
Performance Optimization and JavaScript Best Practices
Performance Optimization and JavaScript Best PracticesPerformance Optimization and JavaScript Best Practices
Performance Optimization and JavaScript Best Practices
 
ExtJs Basic Part-1
ExtJs Basic Part-1ExtJs Basic Part-1
ExtJs Basic Part-1
 
Utopia Kindgoms scaling case: From 4 to 50K users
Utopia Kindgoms scaling case: From 4 to 50K usersUtopia Kindgoms scaling case: From 4 to 50K users
Utopia Kindgoms scaling case: From 4 to 50K users
 
Node Boot Camp
Node Boot CampNode Boot Camp
Node Boot Camp
 
Celery - A Distributed Task Queue
Celery - A Distributed Task QueueCelery - A Distributed Task Queue
Celery - A Distributed Task Queue
 
Mongoose: MongoDB object modelling for Node.js
Mongoose: MongoDB object modelling for Node.jsMongoose: MongoDB object modelling for Node.js
Mongoose: MongoDB object modelling for Node.js
 
iOS 2 - The practical Stuff
iOS 2 - The practical StuffiOS 2 - The practical Stuff
iOS 2 - The practical Stuff
 
JavaScript and UI Architecture Best Practices
JavaScript and UI Architecture Best PracticesJavaScript and UI Architecture Best Practices
JavaScript and UI Architecture Best Practices
 
Ten useful JavaScript tips & best practices
Ten useful JavaScript tips & best practicesTen useful JavaScript tips & best practices
Ten useful JavaScript tips & best practices
 
Codegeneration With Xtend
Codegeneration With XtendCodegeneration With Xtend
Codegeneration With Xtend
 
Functionnal view modelling
Functionnal view modelling Functionnal view modelling
Functionnal view modelling
 
J Query The Write Less Do More Javascript Library
J Query   The Write Less Do More Javascript LibraryJ Query   The Write Less Do More Javascript Library
J Query The Write Less Do More Javascript Library
 
Javascript and Jquery Best practices
Javascript and Jquery Best practicesJavascript and Jquery Best practices
Javascript and Jquery Best practices
 
Workshop 8: Templating: Handlebars, DustJS
Workshop 8: Templating: Handlebars, DustJSWorkshop 8: Templating: Handlebars, DustJS
Workshop 8: Templating: Handlebars, DustJS
 

Similar to java script

11. session 11 functions and objects
11. session 11   functions and objects11. session 11   functions and objects
11. session 11 functions and objects
Phúc Đỗ
 
Unit Testing Express and Koa Middleware in ES2015
Unit Testing Express and Koa Middleware in ES2015Unit Testing Express and Koa Middleware in ES2015
Unit Testing Express and Koa Middleware in ES2015
Morris Singer
 
Intro to Javascript
Intro to JavascriptIntro to Javascript
Intro to Javascript
Anjan Banda
 
WD programs descriptions.docx
WD programs descriptions.docxWD programs descriptions.docx
WD programs descriptions.docx
anjani pavan kumar
 
DIWE - Advanced PHP Concepts
DIWE - Advanced PHP ConceptsDIWE - Advanced PHP Concepts
DIWE - Advanced PHP Concepts
Rasan Samarasinghe
 
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
Dmitry Soshnikov
 
Developing web-apps like it's 2013
Developing web-apps like it's 2013Developing web-apps like it's 2013
Developing web-apps like it's 2013
Laurent_VB
 
Drupaljam xl 2019 presentation multilingualism makes better programmers
Drupaljam xl 2019 presentation   multilingualism makes better programmersDrupaljam xl 2019 presentation   multilingualism makes better programmers
Drupaljam xl 2019 presentation multilingualism makes better programmers
Alexander Varwijk
 
JQuery Presentation
JQuery PresentationJQuery Presentation
JQuery Presentation
Sony Jain
 
Java script advance-auroskills (2)
Java script advance-auroskills (2)Java script advance-auroskills (2)
Java script advance-auroskills (2)
BoneyGawande
 
JavaScript(Es5) Interview Questions & Answers
JavaScript(Es5)  Interview Questions & AnswersJavaScript(Es5)  Interview Questions & Answers
JavaScript(Es5) Interview Questions & Answers
Ratnala Charan kumar
 
ZendCon2010 The Doctrine Project
ZendCon2010 The Doctrine ProjectZendCon2010 The Doctrine Project
ZendCon2010 The Doctrine Project
Jonathan Wage
 
Php & my sql
Php & my sqlPhp & my sql
Php & my sql
Norhisyam Dasuki
 
How to Bring Common UI Patterns to ADF
How to Bring Common UI Patterns to ADF How to Bring Common UI Patterns to ADF
How to Bring Common UI Patterns to ADF
Luc Bors
 
What is new in Java 8
What is new in Java 8What is new in Java 8
What is new in Java 8
Sandeep Kr. Singh
 
jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginners
Divakar Gu
 
How te bring common UI patterns to ADF
How te bring common UI patterns to ADFHow te bring common UI patterns to ADF
How te bring common UI patterns to ADF
Getting value from IoT, Integration and Data Analytics
 
lab4_php
lab4_phplab4_php
lab4_php
tutorialsruby
 
lab4_php
lab4_phplab4_php
lab4_php
tutorialsruby
 
EContent_11_2023_04_09_11_30_38_Unit_3_Objects_and_Classespptx__2023_03_20_12...
EContent_11_2023_04_09_11_30_38_Unit_3_Objects_and_Classespptx__2023_03_20_12...EContent_11_2023_04_09_11_30_38_Unit_3_Objects_and_Classespptx__2023_03_20_12...
EContent_11_2023_04_09_11_30_38_Unit_3_Objects_and_Classespptx__2023_03_20_12...
vekariyakashyap
 

Similar to java script (20)

11. session 11 functions and objects
11. session 11   functions and objects11. session 11   functions and objects
11. session 11 functions and objects
 
Unit Testing Express and Koa Middleware in ES2015
Unit Testing Express and Koa Middleware in ES2015Unit Testing Express and Koa Middleware in ES2015
Unit Testing Express and Koa Middleware in ES2015
 
Intro to Javascript
Intro to JavascriptIntro to Javascript
Intro to Javascript
 
WD programs descriptions.docx
WD programs descriptions.docxWD programs descriptions.docx
WD programs descriptions.docx
 
DIWE - Advanced PHP Concepts
DIWE - Advanced PHP ConceptsDIWE - Advanced PHP Concepts
DIWE - Advanced PHP Concepts
 
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
 
Developing web-apps like it's 2013
Developing web-apps like it's 2013Developing web-apps like it's 2013
Developing web-apps like it's 2013
 
Drupaljam xl 2019 presentation multilingualism makes better programmers
Drupaljam xl 2019 presentation   multilingualism makes better programmersDrupaljam xl 2019 presentation   multilingualism makes better programmers
Drupaljam xl 2019 presentation multilingualism makes better programmers
 
JQuery Presentation
JQuery PresentationJQuery Presentation
JQuery Presentation
 
Java script advance-auroskills (2)
Java script advance-auroskills (2)Java script advance-auroskills (2)
Java script advance-auroskills (2)
 
JavaScript(Es5) Interview Questions & Answers
JavaScript(Es5)  Interview Questions & AnswersJavaScript(Es5)  Interview Questions & Answers
JavaScript(Es5) Interview Questions & Answers
 
ZendCon2010 The Doctrine Project
ZendCon2010 The Doctrine ProjectZendCon2010 The Doctrine Project
ZendCon2010 The Doctrine Project
 
Php & my sql
Php & my sqlPhp & my sql
Php & my sql
 
How to Bring Common UI Patterns to ADF
How to Bring Common UI Patterns to ADF How to Bring Common UI Patterns to ADF
How to Bring Common UI Patterns to ADF
 
What is new in Java 8
What is new in Java 8What is new in Java 8
What is new in Java 8
 
jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginners
 
How te bring common UI patterns to ADF
How te bring common UI patterns to ADFHow te bring common UI patterns to ADF
How te bring common UI patterns to ADF
 
lab4_php
lab4_phplab4_php
lab4_php
 
lab4_php
lab4_phplab4_php
lab4_php
 
EContent_11_2023_04_09_11_30_38_Unit_3_Objects_and_Classespptx__2023_03_20_12...
EContent_11_2023_04_09_11_30_38_Unit_3_Objects_and_Classespptx__2023_03_20_12...EContent_11_2023_04_09_11_30_38_Unit_3_Objects_and_Classespptx__2023_03_20_12...
EContent_11_2023_04_09_11_30_38_Unit_3_Objects_and_Classespptx__2023_03_20_12...
 

More from monikadeshmane

File system node js
File system node jsFile system node js
File system node js
monikadeshmane
 
Nodejs buffers
Nodejs buffersNodejs buffers
Nodejs buffers
monikadeshmane
 
Nodejs basics
Nodejs basicsNodejs basics
Nodejs basics
monikadeshmane
 
Chap 5 php files part-2
Chap 5 php files   part-2Chap 5 php files   part-2
Chap 5 php files part-2
monikadeshmane
 
Chap 5 php files part 1
Chap 5 php files part 1Chap 5 php files part 1
Chap 5 php files part 1
monikadeshmane
 
Chap4 oop class (php) part 2
Chap4 oop class (php) part 2Chap4 oop class (php) part 2
Chap4 oop class (php) part 2
monikadeshmane
 
Chap4 oop class (php) part 1
Chap4 oop class (php) part 1Chap4 oop class (php) part 1
Chap4 oop class (php) part 1
monikadeshmane
 
Chap 3php array part4
Chap 3php array part4Chap 3php array part4
Chap 3php array part4
monikadeshmane
 
Chap 3php array part 3
Chap 3php array part 3Chap 3php array part 3
Chap 3php array part 3
monikadeshmane
 
Chap 3php array part 2
Chap 3php array part 2Chap 3php array part 2
Chap 3php array part 2
monikadeshmane
 
Chap 3php array part1
Chap 3php array part1Chap 3php array part1
Chap 3php array part1
monikadeshmane
 
PHP function
PHP functionPHP function
PHP function
monikadeshmane
 
php string part 4
php string part 4php string part 4
php string part 4
monikadeshmane
 
php string part 3
php string part 3php string part 3
php string part 3
monikadeshmane
 
php string-part 2
php string-part 2php string-part 2
php string-part 2
monikadeshmane
 
PHP string-part 1
PHP string-part 1PHP string-part 1
PHP string-part 1
monikadeshmane
 
ip1clientserver model
 ip1clientserver model ip1clientserver model
ip1clientserver model
monikadeshmane
 
Chap1introppt2php(finally done)
Chap1introppt2php(finally done)Chap1introppt2php(finally done)
Chap1introppt2php(finally done)
monikadeshmane
 
Chap1introppt1php basic
Chap1introppt1php basicChap1introppt1php basic
Chap1introppt1php basic
monikadeshmane
 

More from monikadeshmane (19)

File system node js
File system node jsFile system node js
File system node js
 
Nodejs buffers
Nodejs buffersNodejs buffers
Nodejs buffers
 
Nodejs basics
Nodejs basicsNodejs basics
Nodejs basics
 
Chap 5 php files part-2
Chap 5 php files   part-2Chap 5 php files   part-2
Chap 5 php files part-2
 
Chap 5 php files part 1
Chap 5 php files part 1Chap 5 php files part 1
Chap 5 php files part 1
 
Chap4 oop class (php) part 2
Chap4 oop class (php) part 2Chap4 oop class (php) part 2
Chap4 oop class (php) part 2
 
Chap4 oop class (php) part 1
Chap4 oop class (php) part 1Chap4 oop class (php) part 1
Chap4 oop class (php) part 1
 
Chap 3php array part4
Chap 3php array part4Chap 3php array part4
Chap 3php array part4
 
Chap 3php array part 3
Chap 3php array part 3Chap 3php array part 3
Chap 3php array part 3
 
Chap 3php array part 2
Chap 3php array part 2Chap 3php array part 2
Chap 3php array part 2
 
Chap 3php array part1
Chap 3php array part1Chap 3php array part1
Chap 3php array part1
 
PHP function
PHP functionPHP function
PHP function
 
php string part 4
php string part 4php string part 4
php string part 4
 
php string part 3
php string part 3php string part 3
php string part 3
 
php string-part 2
php string-part 2php string-part 2
php string-part 2
 
PHP string-part 1
PHP string-part 1PHP string-part 1
PHP string-part 1
 
ip1clientserver model
 ip1clientserver model ip1clientserver model
ip1clientserver model
 
Chap1introppt2php(finally done)
Chap1introppt2php(finally done)Chap1introppt2php(finally done)
Chap1introppt2php(finally done)
 
Chap1introppt1php basic
Chap1introppt1php basicChap1introppt1php basic
Chap1introppt1php basic
 

Recently uploaded

LEARNING TO LIVE WITH LAWS OF MOTION .pptx
LEARNING TO LIVE WITH LAWS OF MOTION .pptxLEARNING TO LIVE WITH LAWS OF MOTION .pptx
LEARNING TO LIVE WITH LAWS OF MOTION .pptx
yourprojectpartner05
 
GBSN - Biochemistry (Unit 6) Chemistry of Proteins
GBSN - Biochemistry (Unit 6) Chemistry of ProteinsGBSN - Biochemistry (Unit 6) Chemistry of Proteins
GBSN - Biochemistry (Unit 6) Chemistry of Proteins
Areesha Ahmad
 
Introduction_Ch_01_Biotech Biotechnology course .pptx
Introduction_Ch_01_Biotech Biotechnology course .pptxIntroduction_Ch_01_Biotech Biotechnology course .pptx
Introduction_Ch_01_Biotech Biotechnology course .pptx
QusayMaghayerh
 
Signatures of wave erosion in Titan’s coasts
Signatures of wave erosion in Titan’s coastsSignatures of wave erosion in Titan’s coasts
Signatures of wave erosion in Titan’s coasts
Sérgio Sacani
 
2001_Book_HumanChromosomes - Genéticapdf
2001_Book_HumanChromosomes - Genéticapdf2001_Book_HumanChromosomes - Genéticapdf
2001_Book_HumanChromosomes - Genéticapdf
lucianamillenium
 
TOPIC OF DISCUSSION: CENTRIFUGATION SLIDESHARE.pptx
TOPIC OF DISCUSSION: CENTRIFUGATION SLIDESHARE.pptxTOPIC OF DISCUSSION: CENTRIFUGATION SLIDESHARE.pptx
TOPIC OF DISCUSSION: CENTRIFUGATION SLIDESHARE.pptx
shubhijain836
 
BIRDS DIVERSITY OF SOOTEA BISWANATH ASSAM.ppt.pptx
BIRDS  DIVERSITY OF SOOTEA BISWANATH ASSAM.ppt.pptxBIRDS  DIVERSITY OF SOOTEA BISWANATH ASSAM.ppt.pptx
BIRDS DIVERSITY OF SOOTEA BISWANATH ASSAM.ppt.pptx
goluk9330
 
Microbiology of Central Nervous System INFECTIONS.pdf
Microbiology of Central Nervous System INFECTIONS.pdfMicrobiology of Central Nervous System INFECTIONS.pdf
Microbiology of Central Nervous System INFECTIONS.pdf
sammy700571
 
SDSS1335+0728: The awakening of a ∼ 106M⊙ black hole⋆
SDSS1335+0728: The awakening of a ∼ 106M⊙ black hole⋆SDSS1335+0728: The awakening of a ∼ 106M⊙ black hole⋆
SDSS1335+0728: The awakening of a ∼ 106M⊙ black hole⋆
Sérgio Sacani
 
CLASS 12th CHEMISTRY SOLID STATE ppt (Animated)
CLASS 12th CHEMISTRY SOLID STATE ppt (Animated)CLASS 12th CHEMISTRY SOLID STATE ppt (Animated)
CLASS 12th CHEMISTRY SOLID STATE ppt (Animated)
eitps1506
 
Male reproduction physiology by Suyash Garg .pptx
Male reproduction physiology by Suyash Garg .pptxMale reproduction physiology by Suyash Garg .pptx
Male reproduction physiology by Suyash Garg .pptx
suyashempire
 
Mechanisms and Applications of Antiviral Neutralizing Antibodies - Creative B...
Mechanisms and Applications of Antiviral Neutralizing Antibodies - Creative B...Mechanisms and Applications of Antiviral Neutralizing Antibodies - Creative B...
Mechanisms and Applications of Antiviral Neutralizing Antibodies - Creative B...
Creative-Biolabs
 
(June 12, 2024) Webinar: Development of PET theranostics targeting the molecu...
(June 12, 2024) Webinar: Development of PET theranostics targeting the molecu...(June 12, 2024) Webinar: Development of PET theranostics targeting the molecu...
(June 12, 2024) Webinar: Development of PET theranostics targeting the molecu...
Scintica Instrumentation
 
11.1 Role of physical biological in deterioration of grains.pdf
11.1 Role of physical biological in deterioration of grains.pdf11.1 Role of physical biological in deterioration of grains.pdf
11.1 Role of physical biological in deterioration of grains.pdf
PirithiRaju
 
Discovery of An Apparent Red, High-Velocity Type Ia Supernova at 𝐳 = 2.9 wi...
Discovery of An Apparent Red, High-Velocity Type Ia Supernova at  𝐳 = 2.9  wi...Discovery of An Apparent Red, High-Velocity Type Ia Supernova at  𝐳 = 2.9  wi...
Discovery of An Apparent Red, High-Velocity Type Ia Supernova at 𝐳 = 2.9 wi...
Sérgio Sacani
 
Sexuality - Issues, Attitude and Behaviour - Applied Social Psychology - Psyc...
Sexuality - Issues, Attitude and Behaviour - Applied Social Psychology - Psyc...Sexuality - Issues, Attitude and Behaviour - Applied Social Psychology - Psyc...
Sexuality - Issues, Attitude and Behaviour - Applied Social Psychology - Psyc...
PsychoTech Services
 
Physiology of Nervous System presentation.pptx
Physiology of Nervous System presentation.pptxPhysiology of Nervous System presentation.pptx
Physiology of Nervous System presentation.pptx
fatima132662
 
Candidate young stellar objects in the S-cluster: Kinematic analysis of a sub...
Candidate young stellar objects in the S-cluster: Kinematic analysis of a sub...Candidate young stellar objects in the S-cluster: Kinematic analysis of a sub...
Candidate young stellar objects in the S-cluster: Kinematic analysis of a sub...
Sérgio Sacani
 
Methods of grain storage Structures in India.pdf
Methods of grain storage Structures in India.pdfMethods of grain storage Structures in India.pdf
Methods of grain storage Structures in India.pdf
PirithiRaju
 
Summary Of transcription and Translation.pdf
Summary Of transcription and Translation.pdfSummary Of transcription and Translation.pdf
Summary Of transcription and Translation.pdf
vadgavevedant86
 

Recently uploaded (20)

LEARNING TO LIVE WITH LAWS OF MOTION .pptx
LEARNING TO LIVE WITH LAWS OF MOTION .pptxLEARNING TO LIVE WITH LAWS OF MOTION .pptx
LEARNING TO LIVE WITH LAWS OF MOTION .pptx
 
GBSN - Biochemistry (Unit 6) Chemistry of Proteins
GBSN - Biochemistry (Unit 6) Chemistry of ProteinsGBSN - Biochemistry (Unit 6) Chemistry of Proteins
GBSN - Biochemistry (Unit 6) Chemistry of Proteins
 
Introduction_Ch_01_Biotech Biotechnology course .pptx
Introduction_Ch_01_Biotech Biotechnology course .pptxIntroduction_Ch_01_Biotech Biotechnology course .pptx
Introduction_Ch_01_Biotech Biotechnology course .pptx
 
Signatures of wave erosion in Titan’s coasts
Signatures of wave erosion in Titan’s coastsSignatures of wave erosion in Titan’s coasts
Signatures of wave erosion in Titan’s coasts
 
2001_Book_HumanChromosomes - Genéticapdf
2001_Book_HumanChromosomes - Genéticapdf2001_Book_HumanChromosomes - Genéticapdf
2001_Book_HumanChromosomes - Genéticapdf
 
TOPIC OF DISCUSSION: CENTRIFUGATION SLIDESHARE.pptx
TOPIC OF DISCUSSION: CENTRIFUGATION SLIDESHARE.pptxTOPIC OF DISCUSSION: CENTRIFUGATION SLIDESHARE.pptx
TOPIC OF DISCUSSION: CENTRIFUGATION SLIDESHARE.pptx
 
BIRDS DIVERSITY OF SOOTEA BISWANATH ASSAM.ppt.pptx
BIRDS  DIVERSITY OF SOOTEA BISWANATH ASSAM.ppt.pptxBIRDS  DIVERSITY OF SOOTEA BISWANATH ASSAM.ppt.pptx
BIRDS DIVERSITY OF SOOTEA BISWANATH ASSAM.ppt.pptx
 
Microbiology of Central Nervous System INFECTIONS.pdf
Microbiology of Central Nervous System INFECTIONS.pdfMicrobiology of Central Nervous System INFECTIONS.pdf
Microbiology of Central Nervous System INFECTIONS.pdf
 
SDSS1335+0728: The awakening of a ∼ 106M⊙ black hole⋆
SDSS1335+0728: The awakening of a ∼ 106M⊙ black hole⋆SDSS1335+0728: The awakening of a ∼ 106M⊙ black hole⋆
SDSS1335+0728: The awakening of a ∼ 106M⊙ black hole⋆
 
CLASS 12th CHEMISTRY SOLID STATE ppt (Animated)
CLASS 12th CHEMISTRY SOLID STATE ppt (Animated)CLASS 12th CHEMISTRY SOLID STATE ppt (Animated)
CLASS 12th CHEMISTRY SOLID STATE ppt (Animated)
 
Male reproduction physiology by Suyash Garg .pptx
Male reproduction physiology by Suyash Garg .pptxMale reproduction physiology by Suyash Garg .pptx
Male reproduction physiology by Suyash Garg .pptx
 
Mechanisms and Applications of Antiviral Neutralizing Antibodies - Creative B...
Mechanisms and Applications of Antiviral Neutralizing Antibodies - Creative B...Mechanisms and Applications of Antiviral Neutralizing Antibodies - Creative B...
Mechanisms and Applications of Antiviral Neutralizing Antibodies - Creative B...
 
(June 12, 2024) Webinar: Development of PET theranostics targeting the molecu...
(June 12, 2024) Webinar: Development of PET theranostics targeting the molecu...(June 12, 2024) Webinar: Development of PET theranostics targeting the molecu...
(June 12, 2024) Webinar: Development of PET theranostics targeting the molecu...
 
11.1 Role of physical biological in deterioration of grains.pdf
11.1 Role of physical biological in deterioration of grains.pdf11.1 Role of physical biological in deterioration of grains.pdf
11.1 Role of physical biological in deterioration of grains.pdf
 
Discovery of An Apparent Red, High-Velocity Type Ia Supernova at 𝐳 = 2.9 wi...
Discovery of An Apparent Red, High-Velocity Type Ia Supernova at  𝐳 = 2.9  wi...Discovery of An Apparent Red, High-Velocity Type Ia Supernova at  𝐳 = 2.9  wi...
Discovery of An Apparent Red, High-Velocity Type Ia Supernova at 𝐳 = 2.9 wi...
 
Sexuality - Issues, Attitude and Behaviour - Applied Social Psychology - Psyc...
Sexuality - Issues, Attitude and Behaviour - Applied Social Psychology - Psyc...Sexuality - Issues, Attitude and Behaviour - Applied Social Psychology - Psyc...
Sexuality - Issues, Attitude and Behaviour - Applied Social Psychology - Psyc...
 
Physiology of Nervous System presentation.pptx
Physiology of Nervous System presentation.pptxPhysiology of Nervous System presentation.pptx
Physiology of Nervous System presentation.pptx
 
Candidate young stellar objects in the S-cluster: Kinematic analysis of a sub...
Candidate young stellar objects in the S-cluster: Kinematic analysis of a sub...Candidate young stellar objects in the S-cluster: Kinematic analysis of a sub...
Candidate young stellar objects in the S-cluster: Kinematic analysis of a sub...
 
Methods of grain storage Structures in India.pdf
Methods of grain storage Structures in India.pdfMethods of grain storage Structures in India.pdf
Methods of grain storage Structures in India.pdf
 
Summary Of transcription and Translation.pdf
Summary Of transcription and Translation.pdfSummary Of transcription and Translation.pdf
Summary Of transcription and Translation.pdf
 

java script

  • 2. Syllabus : What we learn? See link - https://prezi.com/view/NNmyKQS4eeL9lz89bQyz/  Javascript basics  Introduction to Node JS (framework to run JS without browser anywhere) • Node JS Modules • NPM • Web Server • File system • Events • Databases • Express JS  Introduction to DJango (quick & easy to develop app with minimum code)  Setup  URL pattern  Forms &Validation Monica Deshmane(H.V.Desai College,Pune) 2
  • 3. chap 1 Java Script Basics 1.1 Java Script data types 1.2 Variables, Functions, Events, Regular Expressions 1.3 Array and Objects in Java Script 1.4 Java Script HTML DOM 1.5 Promises and Callbacks
  • 4. Introduction JavaScript is the scripting language for HTML and understood by the Web. JavaScript is easy to learn. JavaScript is made up of the 3 languages : 1. HTML for look & Feel. 2. CSS to specify the layout or style. 3. JavaScript for Event Handling.
  • 5. The <script> Tag Ex. How to write JS? <script type="text/javascript"> var i = 10; if (i < 5) { // some code } </script>
  • 6. The <script> Tag Attributes of <script> 1. async- script is executed asynchronously (only for external scripts) 2. charset –charset Specifies the character encoding format. 3. defer -Specifies that script is executed when the page has finished parsing 4. src - Specifies the URL of an external script file 5. type - Specifies the media type of the script 6. Lang- To specify which language to use.
  • 7. The <script> Tag in < Body> Script gets executed automatcally when program runs or we can call by function call. <html> <body> <p id=“p1">A Paragraph</p> <Input type="button" onclick="myFunction()“ value=“change”> <script> function myFunction() { document.getElementById(“p1").innerHTML = "Paragraph changed."; } </script> </body> </html>
  • 8. The <script> Tag in < Head> The function must be invoked (called) when event occurs . Ex. button is clicked: <html> <head> <script> function myFunction() { document.getElementById(“p1").innerHTML = "Paragraph changed."; } </script></head> <body> <p id=“p1">A Paragraph</p> <Input type="button" onclick="myFunction()">Try it</Input> </body></html> https://www.w3schools.com/js/tryit.asp?filename=tryjs_intro_inner_html
  • 9. Java Script data types 1) String var Name = “parth"; // String 2) Number var length = 36; // Number 3) Boolean Booleans can only have two values: true or false. 4) Undefined var x = 5; var y = 5; (x == y) // Returns true typeof (3) // Returns "number" to return data type of variable typeof undefined // undefined monica Deshmane(H.V.Desai College,Pune) 1) Primitaive data type
  • 10. Java Script data types 1) Function function myFunction() { } 2) Object var x = {firstName:"John", lastName:“Ray"}; // Object 3) Array var cars = [“suzuki", "VagonR", "BMW"]; //array var person = null; //null //diffrence between null & undefined 1) typeof undefined // undefined typeof null // object 2) null === undefined // false null == undefined // true monica Deshmane(H.V.Desai College,Pune) 2)complex data types
  • 11. JS Types:Revise You can divide JavaScript types into 2 groups 1) primitive - are number, Boolean, string, null 2) complex -are array ,functions ,and objects //primitive Var A=5; Var B=A; B=6; A; //5 B; //6 //complex or reference types Var A=[2,3]; Var B=A; B[0]=3; A[0]; //3 B[0]; //3
  • 12. JavaScript variables are used for storing data values. Same rules of variables in java are followed. var x = 5; var y = 6; var z = x + y; also learn- local variables, global variables, static variables Java Script variables monica Deshmane(H.V.Desai College,Pune)
  • 13. A JavaScript function is a block of code to perform a particular task. executed when someone invokes / calls it. Syntax:- function name(para1, para2, para3) { // code to be executed } Java Script Functions monica Deshmane(H.V.Desai College,Pune)
  • 14. Function Invocation i.e call needed. Return value- Functions often compute a return value. The return value is "returned" back to the "caller". Example- var x = myFunction(10, 3); // Function is called, return value will assigned to x function myFunction(a, b) { return a * b; // Function returns the product of a and b } Java Script Functions monica Deshmane(H.V.Desai College,Pune)
  • 15. var f=function f() { typeof f== “function”; //true window==this; //true //as this is global object } .call & .apply method-To change reference of this to any other object when calling function. function a() {this.a==‘b’; //true} funcation a(b,c){ b==‘first’; //true c==‘second’; //true } a.call((a:’b’),’first’,’second’); //call takes list of parameters to pass function a.apply({a:’b’},[’first’,’second’]); //apply takes array of parameters to pass function monica Deshmane(H.V.Desai College,Pune) Some concepts about function..
  • 16. Java Script Events Event Description onChange An HTML element has been changed onClick The user clicks an HTML element / control onMouseOver The user moves the mouse over an HTML element onMouseOut The user moves the mouse away from an HTML element onKeydown The hits pushes a keyboard key onLoad After loading the page onFocus When perticular control is hilighted See demo online monica Deshmane(H.V.Desai College,Pune)
  • 17. •e.g. •<button onclick="displayDate()“>The time is?</button> <body onload=“display()”>….</body> <input type=text name=“txt” onmouseover = “display()”> <input type=text name=“txt” onFocus = “display()”> Examples of events
  • 18. Regular Expressions( RE) monica Deshmane(H.V.Desai College,Pune) A regular expression is a sequence of characters that forms a pattern. The pattern can be used for 1)search 2)replace 3)Match A regular expression can be made by a single character, or a more complicated /mixed patterns.
  • 19. Patterns Character classes [:alum:] Alphanumeric characters [0-9a-zA-Z] [:alpha:] Alphabetic characters [a-zA-Z] [:blank:] space and tab [ t] [:digit:] Digits [0-9] [:lower:] Lower case letters [a-z] [:upper:] Uppercase letters [A-Z] [:xdigit:] Hexadecimal digit [0-9a-fA-F] range of characters ex. [‘aeiou’]
  • 20. Patterns continue… ? 0 or 1 * 0 or more + 1 or more {n} Exactly n times {n,m} Atleast n, no more than m times {n,} Atleast n times n newline t tab ^ beginning $ end
  • 21. Using String Methods monica Deshmane(H.V.Desai College,Pune) the two string methods used for RE are search() and replace(). 1. The search() method uses an expression to search for a match, and returns the position of the match. var pos = str.search(“/this/”); 2. The replace() method returns a modified string where the pattern is replaced. var txt = str.replace(“/is/”, “this"); 3. match() used to match pattern “hi234”.match(/^ (a-z) +(d{3})$/) 4. exec() -Syntax- pattern.exec(string); The exec() method returns the matched text if it finds a match, otherwise it returns null. “/(hey|ho)/”.exec('h') //h
  • 22. Array in Java Script monica Deshmane(H.V.Desai College,Pune) 1. Array creation • var arr1 = new Array(); OR • var arr2 = [ ]; arr2.push(1); arr2.push(2); //[1,2] arr1.sort(); • var arr3 = [ ‘mat', 'rat', 'bat' ]; 2. Length arr2.length; console.log(arr2); 3. To delete element from array arr3.splice(2, 2); arr.pop(); //see demo on JS.do
  • 23. Array splice in Java Script monica Deshmane(H.V.Desai College,Pune) <script> var lang = ["HTML", "CSS", "JS", "Bootstrap"]; document.write(lang + "<br>"); var removed = lang.splice(2, 1, 'PHP', ‘python') document.write(lang + "<br>"); // HTML,CSS,JS,Bootstrap document.write(removed + "<br>"); // HTML,CSS,PHP,python,Bootstrap // No Removing only Insertion from 2nd index from the ending lang.splice(-2, 0, 'React') // JS document.write(lang) // HTML,CSS,PHP,React,python,Bootstrap </script>
  • 24. Array continue… monica Deshmane(H.V.Desai College,Pune) Array is like u so before the typeof operator will return “object” for arrays more times however you want to check that array is actually an array. Array.isArray returns true for arrays and False for any other values. Array.isArray( new array) // true Array.isArray( [ ] ) // true Array.isArray( null) // false Array.isArray(arguments ) //false
  • 25. Array continue… monica Deshmane(H.V.Desai College,Pune) See –tutorials point javascript arrays array methods • to loop over an array you can use for each (Similar to jquery $.each) [1,2,3].foreach(function value) { console.log (value ); } •To filter elements out of array you can use filter (similar two jQuery grep) [1,2,3].foreach(function value) { return value < 3; } //will return [ 1, 2] •to change value of of each item you can use map (similar to Jquery map) [ 5,10 ,15].map function (value) { return value*2; } // will return [10 ,20 ,30] • also available but less commonly used are the methods- reduce , reduceRight and lastIndexOf.
  • 26. Array continue… monica Deshmane(H.V.Desai College,Pune) •reduceRight:-Subtract the numbers in the array, starting from the right: <script> var numberarr= [175, 50, 25]; document.getElementById(“p1").innerHTML = numberarr.reduceRight(myFunc); function myFunc(total, num) { return total - num; } •Reduce-from left to right •lastIndexOf- const animals = ['Dog', 'Tiger', 'Penguin','Dog']; console.log(animals.lastIndexOf('Dog'));// expected output: 3 console.log(animals.lastIndexOf('Tiger'));// expected output: 1
  • 27. •Object Creation var obj1 = new Object(); var obj2 = { }; var subject = { first_name: "HTML", last_name: "CSS“ , reference: 320 ,website: "java2s.com" }; •add a new property subject.name= "brown"; OR subject["name"] = "brown"; •To delete a new property delete subject.name; •To get all keys from object var obj={a:’aaa’, b:’bbb’ ,c:’ccc’}; Object.keys(obj); //[‘a’ ,’b’, ‘c’] Objects in Java Script
  • 29. The HTML DOM is a standard object model and programming interface for HTML. It contains -The HTML elements as objects -The properties of all HTML elements -The methods to access all HTML elements -The events for all HTML elements DOM CSS- The HTML DOM allows JavaScript to change the style of HTML elements. DOM Animation- create HTML animations using JavaScript DOM Events- allows JavaScript to react to HTML events by event handlers & event Listeners. HTML DOM elements are treated as nodes ,in which elements can be added by createElement() or appendChild() & deleted nodes using remove() or removeChild(). HTML DOM continue…
  • 30. Promises & callback - The promises in Javascript are just that, promises it means that we will do everything possible to achieve the expected result. But, we also know that a promise cannot always be fulfilled for some reason. Just as a promise is in real life, it is in Javascript, represented in another way.
  • 31. Promises Example let promise = new Promise(function(resolve, reject) { // task to accomplish your promise if(/* everything turned out fine */) { resolve('Stuff worked') } else { // for some reason the promise doesn't fulfilled reject(new Error('it broke')) } }); Promises have three unique states: 1. Pending: asynchronous operation has not been completed yet. 2. Fulfilled: operation has completed and returns a value. 3. Rejected: The asynchronous operation fails and the reason why it failed is indicated.
  • 32. Callback function will be executed when an asynchronous operation has been completed. A callback is passed as an argument to an asynchronous operation. Normally, this is passed as the last argument of the function. When a function simply accepts another function as an argument, this contained function is known as a callback function. Callback functions are written like : function sayHello() { console.log('Hello everyone');} setTimeout( sayHello( ), 3000); What we did in the above example was, first to define a function that prints a message to the console. After that, we use a timer called setTimeout (this timer is a native Javascript function). This timer is an asynchronous operation that executes the callback after a certain time. In this example, after 3000ms (3 seconds) will be executed the sayHello() function.
  • 33. Difference between callback and promises 1. promises are easy for running asynchronous tasks to feel like synchronous and also provide catching mechanism which are not in callbacks. 2. Promises are built over callbacks. 3. Promises are a very mighty abstraction, allow clean and better code with less errors. 4. In promises, we attach callbacks on the returned promise object. For callback approach, we normally just pass a callback into a function that would then get called upon completion in order to get the result of something. .