Top Banner
JavaScript Beyond jQuery
61

jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

Aug 22, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

JavaScript BeyondjQuery

Page 2: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

JavaScript BeyondjQuery

★ Traversing The DOM★ Element Objects★ Functions★ Native Objects★ Closures★ Manipulating Data★ Prototypal Inheritance★ Revealing Modules★ Function Composition

Page 3: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

1.TRAVERSING THE DOM

First Let's Start at the Beginning?

Page 4: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

Why Would you Use jQuery?

▸ Browser Support

Page 5: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

Why Would you Use jQuery?

▸ Less Typing.▸ Easier to Learn

Page 6: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

Why Would you Use jQuery?

▸ It already comes packages in WordPress

Page 7: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

USING VANILLAJSIs Generally a lot Easier Than You Think

Page 8: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

Events

Page 9: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

Classes

Page 10: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

DOCUMENT OBJECTMODELLet’s Take a Closer Look

Page 11: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

THE ELEMENT INTERFACE

The Element Interface represents an Object of a Document.

Page 12: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

2.THEJAVASCRIPTFUNCTION

It’s Where Lots of the Magic Happens

Page 13: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

Function Definitions

Page 14: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

JavaScript Functions are First Class Citizens

★ Functions can be assigned to variables and Passed Around.

★ Functions can accept other Functions as arguments.

★ Functions can return other functions.

Page 15: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

BUTMOSTOFALL

Every Function in Javascript is a Function Object

Page 16: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

FUNCTIONOBJECTPROPERTIES & METHODS

Page 17: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

3.JAVASCRIPTOBJECTS

The Building Blocks of the Language.

Page 18: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

Primary Javascript Objects

★ Function★ String★ Array★ Number★ Boolean★ TypeError

Page 19: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

4.JAVASCRIPTCLOSURES

A Function that can be stored as a variable, and that has the special ability to access other variables local to the scope it was created in.

Page 20: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

Javascript Function have access to variable defined above their internal scope.

Page 21: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

Javascript Function can also override external variables with their own version with the same name.

Page 22: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

But Variables defined inside a Javascript Function are not accessible from outside its scope.

Page 23: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

But this highlights one of the top use cases for Closures in Javascript: Immediately-Invoked Function Expression

Page 24: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

Practical IFFE Example

Page 25: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.
Page 26: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

5.MANIPULATINGDATA

The Javascript Array Object Methods

Page 27: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

Array.prototype.map( );

The map() method creates a new array with the results of calling a provided function on every element in this array.

Page 28: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

Array.prototype.map( );

Page 29: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

Array.prototype.map( );

Page 30: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

Array.prototype.filter( );

The filter() method creates a new array with values that pass the test implemented by the function provided.

Page 31: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

Array.prototype.filter( );

Page 32: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

Array.prototype.filter( );

Page 33: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

Array.prototype.reduce( );

The reduce() method applies a function against an accumulator and each value of an array (from left to right) to reduce it to a single value.

Page 34: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

Array.prototype.reduce( );

Page 35: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

Array.prototype.reduce( );

Page 36: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

Array.prototype.reduce( );

Page 37: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

6.PROTOTYPALINHERITANCE

Javascript Objects inheriting from other

Objects

Page 38: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

Class Based Inheritance

In a class based system you can define a Class, which will act asa blueprint for each new Object.

Classes can inherit from other classes to create a hierarchy.

When you create a new object from the class it is considered an Instance of that class.

Page 39: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

Prototype Based Inheritance

Prototype Languages such as Javascript to not have this distinction.

Languages like Javascript simply have Objects, which can inherit from other objects.

Javascript’s Prototypal Inheritance is so hard to understand, because it gives us this new keyword, and tries to mimic class based inheritances.

Page 40: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.
Page 41: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

Classical Inheritance

Page 42: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

Classical Inheritance (continued)

Page 43: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

Factory Function

Page 44: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

Factory Function (Continued)

Page 45: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

Factory Function (Continued)

Page 46: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

Classical Inheritance (Continued)

Page 47: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

Composition vs Inheritance

Page 48: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

7.REVEALINGMODULE PATTERN

Another Way to Build Objects

Page 49: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

Function + Closure = Revealing Module Pattern

Page 50: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

Revealing Module Pattern

Page 51: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

8.FUNCTIONCOMPOSITION

Functions As Ingredients

Page 52: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

FUNCTIONCOMPOSITION

Page 53: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

FUNCTIONCOMPOSITION

Page 54: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

FUNCTIONCOMPOSITION

Page 55: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

FUNCTIONCOMPOSITION

Page 56: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

FUNCTIONCOMPOSITION

Page 57: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

Resources

Page 58: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

Resources

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Closures

Page 59: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

Resources

http://youmightnotneedjquery.com/

Page 60: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

Develop With WP

Page 61: jQuery Beyond JavaScript - 2016 WordCamp DaytonWhy Would you Use jQuery? It already comes packages in WordPress. USING VANILLA JS Is Generally a lot Easier Than You Think. Events.

Hello my Name is Bobby Bryant. I am A web developer at 10up

twitter: /mrbobbybryantyoutube: /developwithwpgithub: /mrbobbybryant