J query (intermediate)

18
JQUERY – INTERMEDIATE 1

Transcript of J query (intermediate)

Page 1: J query (intermediate)

1

JQUERY – INTERMEDIATE

Page 2: J query (intermediate)

2

ROAD MAP

1. JS - Present, Past & Future

2. Javascript Vs jQuery

3. JS Engine

4. Value & Identity

5. Class Vs Prototype

6. Object

7. Delegation

8. Closures

9. DOM & Left things (Next Time)

Page 3: J query (intermediate)

3ALLONGE (FRENCH) = ELONGATE

Page 4: J query (intermediate)

4

JS – PRESENT, PAST & FUTUREJava Script

jQuery, Mootools, YUI etc(Client Side Framework)

MVC (Model, View & Controller)

Client Side Server Side

Angular JS(By Google)Backbone JS

etc

Node JSNarwhal

etc

Page 5: J query (intermediate)

5

WHAT WE CAN NOT DO IN JS

- File I/O

- Using Ajax, JavaScript can send a request to the server. This request can read a file in XML or plain text format but it cannot write to a file unless the file called on the server actually runs as a script to do the file write for you.

- Networking

- DB APIs

- unless you use Ajax and have a server side script perform the database accesses for you.

- So, Node or other JSs has come.

Page 6: J query (intermediate)

6

Page 7: J query (intermediate)

7

WHAT IS JAVASCRIPT ENGINE ?

A JavaScript engine is process virtual machine which interprets and executes JavaScript (also known as ECMAScript).

Source – WiKi

Web Browsers Engine Used

FF SpiderMonkey

Chrome V8

Safari JavascriptCore

IE Chakra

Page 8: J query (intermediate)

8

VALUES & IDENTITY

var n = "1";

console.log(n==1);

console.log(n===1);

Page 9: J query (intermediate)

9

JAVASCRIPT BY OOPS, BUT NOT "CLASS"-ICAL LANGUAGES.

- Object-Oriented

- Class – Object Relation

- But there are no classes in JavaScript. Functions can be used to somewhat simulate classes.

- And when it comes to inheritance, objects inherit from objects, not classes from classes as in the "class"-ical languages.

- So, Java Script is NOT a "class"-ical languages.

Page 10: J query (intermediate)

10

CLASS VS PROTOTYPE

- Yes, there are no classes in JavaScript.

- But Functions can be used to somewhat simulate classes.

- A drawback of CLASS is that the method getInfo() is recreated every time you create a new object.

- A more inexpensive way is to add getInfo() to the prototype of the constructor function.

- Class - Based :

- Code reuse through Inheritance- Class - Object communication

- Prototype - Based :

- Code reuse through delegation- Class - Object communication

Page 11: J query (intermediate)

11

OBJECT

Page 12: J query (intermediate)

12

DELEGATION

Page 13: J query (intermediate)

13

DELEGATION OF MESSAGES

Page 14: J query (intermediate)

14

VARIABLE SCOPE

Page 15: J query (intermediate)

15

CLOSURES

Page 16: J query (intermediate)

16

EXAMPLE FOR CLOSURES

Page 17: J query (intermediate)

17

HOW CLOSURES WORKS?

Page 18: J query (intermediate)

18