javascript: enter the dragon

Post on 15-May-2015

3.617 Views

Category:

Technology

2 Downloads

Preview:

Click to see full reader

TRANSCRIPT

JavaScript

JavaScriptEnter the Dragon

Most misunderstood language

You have no choice

…but you have plenty of options

JavaScript

JavaScript human body

“If you have a body, you are an athlete”

Bill Bowerman, co-founder of Nike.

If you code for the Web,you are a JavaScript Developer

Control

Why you “unfit”?

Why your JavaScript sucks?

“This is not important”

“I don’t need it any more, it’s XXI century”

“I am good enough!”

“It’s way too complicated”

“I don’t have time for this”

Kyle Maynard — MMA fighter

Kyle Maynard — MMA fighter

Kyle Maynard — MMA fighter

Excuses… Let’s hear yours again

There are no shortcuts

“Those who are unawarethey are walking in darknesswill never seek the light.”

Bruce Lee

Six essential bits

Six pack

Types & type coercion1

objectnumber

stringboolean

nullundefined

5 - "4"5 + "4"+!{}[true]+[1]+[1, 2]7 - "a"7 / 0…

Operators,especially “+” & “==”2

5 + "4"5 + null4 == "4.00"null == undefined0 == false0 == nullnull == false

typeof null == "object"typeof function () {} == "function"

Objects & primitives3

var a = "string";alert(a.length);a.t = 3;alert(a.t);

Functions & constructors4

function f() {};

var a = f, b = f(), c = new f, d = f(f);

Closures5

function add(a) { return function (b) { return a + b; };}

add(3)(4) == 7

Prototype6

Prototypes in JavaScriptin 5 minutes

function f() {};f P

function f() {};f.prototype.x = 3; f P x: 3

function f() {};f.prototype.x = 3;var a = new f;

f P x: 3

a

function f() {};f.prototype.x = 3;var a = new f;a.x = 2;a.y = 1;

f P x: 3

x: 2y: 1

a

function f() {};f.prototype.x = 3;var a = new f;a.x = 2;a.y = 1;var b = new f;

f P x: 3

x: 2y: 1

a b

function f() {};f.prototype.x = 3;var a = new f;a.x = 2;a.y = 1;var b = new f;f.prototype = {z: 0};

f PP2 x: 3z: 0

x: 2y: 1

a b

function f() {};f.prototype.x = 3;var a = new f;a.x = 2;a.y = 1;var b = new f;f.prototype = {z: 0};var c = new f;

f PP2 x: 3z: 0

x: 2y: 1

ac b

function f() {};f.prototype.x = 3;var a = new f;a.x = 2;a.y = 1;var b = new f;f.prototype = {z: 0};var c = new f;

f PP2 x: 3z: 0

x: 2y: 1

ac b

b.constructor == fc.constructor == Object

I didn’t get it…

Function.constructor == Function

Nobody knows what to do

http://www.udel.edu/anthro/neitzel/supplemental%20sportsS09.htm

Different goalsdemand different approaches

Form always follows the function

http://www.flickr.com/photos/sgroi/3228398172/

http

://en

.wik

iped

ia.o

rg/w

iki/

Her

cule

s_of

_the

_For

um_B

oariu

m

http://www.flickr.com/photos/stebbz/2451346427/

Thank You

“A wise man can learn more froma foolish questionthan a fool can learn froma wise answer.”

Bruce Lee

“If you spend too much timethinking about a thing,you’ll never get it done.”

Bruce Lee

top related