SlideShare a Scribd company logo
1 of 142
JavaScript + Arale
        发   帅
web 术   职责
web 术   职责

JavaScript语
web 术   职责

JavaScript语

选择      DOM
web 术   职责

JavaScript语

选择      DOM

Arale
web 术   职责
职责   MVC


 HTML             M


  CSS        样     V


JavaScript    为   C
职责   MVC


 HTML             M


  CSS        样     V


JavaScript    为   C
职责   MVC


 HTML             M


  CSS        样     V


JavaScript    为   C
web 术   职责

JavaScript语

选择      DOM

Arale
JavaScript语
语
语

变   时
语

    变    时

                 number, string,

object, boolean, null, undefined
语

    变    时

                 number, string,

object, boolean, null, undefined
number, string, boolean
             VS.
    Number, String, Boolean
number, string, boolean       传递



             VS.
    Number, String, Boolean
number, string, boolean           传递



             VS.
    Number, String, Boolean   对    传递
number, string, boolean           传递



             VS.
    Number, String, Boolean   对    传递




undefined
         VS.
                null
number, string, boolean              传递



             VS.
    Number, String, Boolean     对        传递




undefined   变   创      赋   应该       传递



         VS.
                null
number, string, boolean                  传递



             VS.
    Number, String, Boolean     对         传递




undefined   变   创      赋   应该        传递



         VS.
                null                传递
var x = new Boolean(false);
if (x) {
    alert('hi'); // Shows 'hi'.
}
var x = new Boolean(false);
if (x) {
    alert('hi'); // Shows 'hi'.
}

var x = Boolean(0);
if (x) {
    alert('hi'); // This will never be alerted.
}
typeof Boolean(0) == 'boolean';
typeof new Boolean(0) == 'object';
function f1(x) {
    var a = 1;
    if(x) {
        var b = 2;
    }
    function f2() {
        var c = 3;
    }
    console.log(a);
    console.log(b);
    console.log(c);
}
f1(4);
function f1(x) {
    var a = 1;        1
    if(x) {           2
        var b = 2;    undefined
    }
    function f2() {
        var c = 3;
    }
    console.log(a);
    console.log(b);
    console.log(c);
}
f1(4);
JavaS
     cript
if (x) {
    function foo() {}
}
if (x) {
    function foo() {}
}
if (x) {                if (x) {
    function foo() {}       var foo = function() {}
}                       }
expression & literal
expression & literal
  function fn() {


      console.log(f1);
      var f1 = function() {
          console.log("f1")
      }
      console.log(f1);


      console.log(f2);
      function f2() {
      }
      console.log(f2);
      var f2 = function() {
          console.log("f3");
      }
      f2();
  }
  fn()
expression & literal
  function fn() {


      console.log(f1);
      var f1 = function() {
          console.log("f1")
      }
      console.log(f1);


      console.log(f2);
      function f2() {
      }
      console.log(f2);
      var f2 = function() {
          console.log("f3");
      }
      f2();
  }
  fn()
expression & literal
  function fn() {


      console.log(f1);
      var f1 = function() {
          console.log("f1")           结
      }
      console.log(f1);         null
                               function
      console.log(f2);
      function f2() {          function
      }                        function
      console.log(f2);
                               f3
      var f2 = function() {
          console.log("f3");
      }
      f2();
  }
  fn()
达为
达为

变    储
达为

变    储

      结   储
达为

变    储

      结   储
达为

变    储

      结   储



为    结
对   prototype
对                 prototype
function Circle(x, y, z) {
    this.x = x;
    this.y = y;
    this.r = r;
    this.getR = function() { return this.r;};
}
//instance method
Circle.prototype.area = function() {
    return this.r * this.r * 3.14159;
}
var c = new Circle(0, 0, 2);
alert(c.area());
对                      prototype
function Circle(x, y, z) {
    this.x = x;
    this.y = y;                                 getR Vs. area
    this.r = r;
    this.getR = function() { return this.r;};
}
//instance method
Circle.prototype.area = function() {
    return this.r * this.r * 3.14159;
}
var c = new Circle(0, 0, 2);
alert(c.area());
对                                  prototype
function Circle(x, y, z) {
    this.x = x;
    this.y = y;                                     getR Vs. area
    this.r = r;
    this.getR = function() { return this.r;};
}
//instance method
Circle.prototype.area = function() {
                                                //static method
    return this.r * this.r * 3.14159;
                                                Circle.getClassName = function() {
}
                                                    return “Circle”;
var c = new Circle(0, 0, 2);
                                                }
alert(c.area());
对                                      prototype
function Circle(x, y, z) {
    this.x = x;
    this.y = y;                                         getR Vs. area
    this.r = r;
    this.getR = function() { return this.r;};
}
//instance method
Circle.prototype.area = function() {
                                                    //static method
    return this.r * this.r * 3.14159;
                                                    Circle.getClassName = function() {
}
                                                        return “Circle”;
var c = new Circle(0, 0, 2);
                                                    }
alert(c.area());

        prototype 对                     实       对           这         为    础
继
继
function ClassA(sColor) {
    this.color = sColor;
}

ClassA.prototype.sayColor = function () {
    alert(this.color);
};

function ClassB(sColor, sName) {
    ClassA.call(this, sColor);
    this.name = sName;
}

ClassB.prototype = new ClassA();

ClassB.prototype.sayName = function () {
    alert(this.name);
};
继
function ClassA(sColor) {
    this.color = sColor;
}

ClassA.prototype.sayColor = function () {

};
    alert(this.color);
                                            对
function ClassB(sColor, sName) {
    ClassA.call(this, sColor);
    this.name = sName;
}

ClassB.prototype = new ClassA();

ClassB.prototype.sayName = function () {
    alert(this.name);
};
继
function ClassA(sColor) {
    this.color = sColor;
}

ClassA.prototype.sayColor = function () {

};
    alert(this.color);
                                            对
function ClassB(sColor, sName) {
    ClassA.call(this, sColor);
    this.name = sName;
}

ClassB.prototype = new ClassA();
                                                链
ClassB.prototype.sayName = function () {
    alert(this.name);
};
继
function ClassA(sColor) {
    this.color = sColor;
}

ClassA.prototype.sayColor = function () {

};
    alert(this.color);
                                            对
function ClassB(sColor, sName) {
    ClassA.call(this, sColor);
    this.name = sName;
}

ClassB.prototype = new ClassA();
                                                链
ClassB.prototype.sayName = function () {
    alert(this.name);
};
继                对                +        链
function ClassA(sColor) {
    this.color = sColor;
}

ClassA.prototype.sayColor = function () {
    alert(this.color);
};

function ClassB(sColor, sName) {
    ClassA.call(this, sColor);
    this.name = sName;
}

ClassB.prototype = new ClassA();

ClassB.prototype.sayName = function () {
    alert(this.name);
};
闭
闭
    编   严

调
闭
      编     严

    调

闭     给

 变      环

      变

    scope chain
闭                 var sMessage = "hello world";
                  function sayHelloWorld() {
                      alert(sMessage);
      编     严
                  }
    调             sayHelloWorld();


闭     给

 变      环

      变

    scope chain
闭                 var sMessage = "hello world";
                  function sayHelloWorld() {
                      alert(sMessage);
      编     严
                  }
    调             sayHelloWorld();

                  var iBaseNum = 10;
闭     给
                  function addNum(iNum1, iNum2) {
                      function doAdd() {
 变      环
                           return iNum1 + iNum2 + iBaseNum;
      变                }
                       return doAdd();
    scope chain   }
闭                 var sMessage = "hello world";
                   function sayHelloWorld() {
                       alert(sMessage);
       编     严
                   }
     调             sayHelloWorld();

                   var iBaseNum = 10;
 闭     给
                   function addNum(iNum1, iNum2) {
                       function doAdd() {
  变      环
                            return iNum1 + iNum2 + iBaseNum;
       变                }
                        return doAdd();
     scope chain   }
简单 说 闭
                                                       义 变
驱动   编
驱动   编
驱动   编
驱动                   编
<button id=”btn” onclick=”alert(‘button clicked!’);”>Click Me!</button>
驱动               编
<button id=”btn” onclick=”alert(‘button clicked!’);”>Click Me!</button>


var btn = document.getElementById(‘btn’);
btn.onclick = function() {
    alert(“button clicked”);
}
驱动                     编
<button id=”btn” onclick=”alert(‘button clicked!’);”>Click Me!</button>


var btn = document.getElementById(‘btn’);
btn.onclick = function() {
    alert(“button clicked”);
}


var btn = document.getElementById(‘btn’);
if(window.addEventListener) {
    btn.addEventListener(‘click’, function() {alert(1);}, false);
} else {
    btn.attachEvent(‘onclick’, function() {alert(1);});
}
驱动                     编
<button id=”btn” onclick=”alert(‘button clicked!’);”>Click Me!</button>


var btn = document.getElementById(‘btn’);
btn.onclick = function() {
    alert(“button clicked”);
}


var btn = document.getElementById(‘btn’);
if(window.addEventListener) {
    btn.addEventListener(‘click’, function() {alert(1);}, false);
} else {
    btn.attachEvent(‘onclick’, function() {alert(1);});
}
click       submit

change      keydown

load        keypress

mouseover   resize

mouseout    scroll

blur        ......
web 术   职责

JavaScript语

选择       DOM

Arale
选择   DOM
DOM
DOM
Document Object Model
DOM
Document Object Model
HTML XML           编    规

   W3C标
DOM
Document Object Model
HTML XML           编        规

   W3C标

 过JS      DOM对          达       页
DOM manipulation
DOM manipulation


 创
DOM manipulation


 创

 删
DOM manipulation


 创

 删

 获     /
DOM manipulation


 创

 删

 获     /

 访问/
DOM
DOM
getElementById                     removeChild

firstChild, lastChild,childNodes   replaceChild
previousSibling, nextSibling,
                                   createElement
parentNode


getElementsByTagNam                createTextNode
e
                                   insertBefore
appendChild
                                   innerHTML
var newP = document.createElement("p");
var txt = 'Kilroy was here.';
var newT = document.createTextNode(txt);
newP.appendChild(newT);
var p2 = document.getElementsByTagName('p')[1];
p2.parentNode.replaceChild(newP,p2);
选择   /selector
选择       /selector


css选择

sizzle
web 术   职责

JavaScript语

选择      DOM

Arale
Arale
Arale
Arale Js

     Arale
Alice
Arale Js

     Arale
Alice
Arale Js

     Arale

                     combo
Alice
Arale Js               maven

     Arale

                     combo
Alice
     Arale Js                maven

           Arale
static server
                           combo
Alice
     Arale Js                maven

           Arale
static server
                           combo
Hello World!
Hello World!


        $E.domReady(function(){
            $("btn").click(function(e){
                alert("Hello Arale!");
            });
        });
Selector
Selector

     id选择   : $(‘id’)
Selector

     id选择   : $(‘id’)

                Node
Selector

     id选择   : $(‘id’)

                Node


      杂选择         $$(selector)
Selector

     id选择   : $(‘id’)

                Node


      杂选择         $$(selector)

                   组      组      节   为Node
Dom & Node
    $D —— 态

    $Node——   对   获   实
Dom & Node
    $D —— 态

    $Node——          对      获   实
           Dom

                  toDom
              getPosition
                 setStyle
       getDocumentWidth
      getDocumentHeight
        getViewportWidth
       getViewportHeight
Dom & Node
    $D —— 态

    $Node——          对        获        实
                            Node
           Dom
                            addClass
                  toDom     removeClass
              getPosition   attr
                 setStyle   inject
       getDocumentWidth     getStyle
      getDocumentHeight     setStyle
        getViewportWidth    next
       getViewportHeight    previous
                            parent
                            query
Event——$E
Event——$E


    $E.domReady(function() {
             //do something
    });
Event——$E
                                  connect
                                disconnect
    $E.domReady(function() {
             //do something      subscribe
    });
                               unsubscribe
                                   publish
                                    trigger
                                  delegate
                                       live
Event——$E
                                  connect
                                disconnect
    $E.domReady(function() {
             //do something      subscribe
    });
                               unsubscribe
                                   publish
                                    trigger
                                  delegate
                                       live
组——$A
组——$A
$A([1,2,3,4,5]).each(function(v, i) {
        console.log(v);
});
组——$A
$A([1,2,3,4,5]).each(function(v, i) {
        console.log(v);
});



 map & reduce
组——$A
$A([1,2,3,4,5]).each(function(v, i) {
        console.log(v);
});



 map & reduce
                    each
                   every
                   some
                     map
                    filter
组——$A
$A([1,2,3,4,5]).each(function(v, i) {
        console.log(v);
});



 map & reduce                           Others:
                    each                clean
                   every                remove
                   some                 combine
                     map                erase
                    filter              include
                                        last
颗   块设计
颗   块设计   combo   务
颗   块设计   combo   务
颗   块设计                             combo   务


    Loader.use(‘arale.http’, function() {
          $Ajax.get(‘url’, {
            success: function() {
            }
          });
    });
A       B
             Loader.use(‘C’, function() {
                  //some code here
             })

    C

    载C 块js                时

A       B还   载              时

载
颗       块设计

    A       B
                 Loader.use(‘C’, function() {
                      //some code here
                 })

        C

        载C 块js                时

    A       B还   载              时

    载
码检
码检
压缩
码检
压缩
编码检测
码检
压缩
          测试
编码检测
码检
压缩
          测试
编码检测
     赖    计
码检
压缩
          测试
编码检测
     赖    计
码检
压缩
          测试
编码检测
     赖    计
码检
压缩
          测试
编码检测           Maven

     赖    计
项

     码检
压缩
          测试
编码检测           Maven

     赖    计
http://arale.alipay.net

http://arale.alipay.net:3000

       发组     http://arale.alipay.net/

wiki/doku.php?id=wigetdevelopment

jsdoc规    http://arale.alipay.net/wiki/

doku.php?id=jsdocstandard
task

       JS实现

   Array#sort

        (delegate)

   Arale             demo
Q&A
Thanks!

More Related Content

What's hot

Clang-tidy: путешествие внутрь AST C++
Clang-tidy: путешествие внутрь AST C++Clang-tidy: путешествие внутрь AST C++
Clang-tidy: путешествие внутрь AST C++corehard_by
 
[C++ Korea] Effective Modern C++ Study, Item 27, 29 - 30
[C++ Korea] Effective Modern C++ Study, Item 27, 29 - 30[C++ Korea] Effective Modern C++ Study, Item 27, 29 - 30
[C++ Korea] Effective Modern C++ Study, Item 27, 29 - 30Chris Ohk
 
Алексей Кутумов, C++ без исключений, часть 3
Алексей Кутумов,  C++ без исключений, часть 3Алексей Кутумов,  C++ без исключений, часть 3
Алексей Кутумов, C++ без исключений, часть 3Platonov Sergey
 
Антон Полухин. C++17
Антон Полухин. C++17Антон Полухин. C++17
Антон Полухин. C++17Sergey Platonov
 
Hyrje openmp
Hyrje openmpHyrje openmp
Hyrje openmpL Dr
 
C++14 reflections
C++14 reflections C++14 reflections
C++14 reflections corehard_by
 
Java & le pattern matching
Java & le pattern matchingJava & le pattern matching
Java & le pattern matchingDidier Plaindoux
 
Тененёв Анатолий, Boost.Asio в алгоритмической торговле
Тененёв Анатолий, Boost.Asio в алгоритмической торговлеТененёв Анатолий, Boost.Asio в алгоритмической торговле
Тененёв Анатолий, Boost.Asio в алгоритмической торговлеPlatonov Sergey
 
ECMAscript 2015 aka ES6 : à la découverte du nouveau javascript
ECMAscript 2015 aka ES6 : à la découverte du nouveau javascriptECMAscript 2015 aka ES6 : à la découverte du nouveau javascript
ECMAscript 2015 aka ES6 : à la découverte du nouveau javascriptmatparisot
 
Java Thread Cronometro
Java Thread CronometroJava Thread Cronometro
Java Thread Cronometrojubacalo
 
Tomografi Delay Time Sederhana
Tomografi Delay Time SederhanaTomografi Delay Time Sederhana
Tomografi Delay Time SederhanaFajar Perdana
 
EJEMPLOS DESARROLLADOS
EJEMPLOS DESARROLLADOSEJEMPLOS DESARROLLADOS
EJEMPLOS DESARROLLADOSDarwin Durand
 
Sobrecarga e Sobrescrita - Preparatório Certificação - OCAJP7 - Aula 2 - F
Sobrecarga e Sobrescrita - Preparatório Certificação - OCAJP7 - Aula 2 - FSobrecarga e Sobrescrita - Preparatório Certificação - OCAJP7 - Aula 2 - F
Sobrecarga e Sobrescrita - Preparatório Certificação - OCAJP7 - Aula 2 - FPaulo Henrique Lerbach Rodrigues
 
โปรแกรมย่อยและฟังก์ชั่นมาตรฐาน
โปรแกรมย่อยและฟังก์ชั่นมาตรฐาน โปรแกรมย่อยและฟังก์ชั่นมาตรฐาน
โปรแกรมย่อยและฟังก์ชั่นมาตรฐาน knangsmiley
 

What's hot (18)

Clang-tidy: путешествие внутрь AST C++
Clang-tidy: путешествие внутрь AST C++Clang-tidy: путешествие внутрь AST C++
Clang-tidy: путешествие внутрь AST C++
 
[C++ Korea] Effective Modern C++ Study, Item 27, 29 - 30
[C++ Korea] Effective Modern C++ Study, Item 27, 29 - 30[C++ Korea] Effective Modern C++ Study, Item 27, 29 - 30
[C++ Korea] Effective Modern C++ Study, Item 27, 29 - 30
 
Алексей Кутумов, C++ без исключений, часть 3
Алексей Кутумов,  C++ без исключений, часть 3Алексей Кутумов,  C++ без исключений, часть 3
Алексей Кутумов, C++ без исключений, часть 3
 
Антон Полухин. C++17
Антон Полухин. C++17Антон Полухин. C++17
Антон Полухин. C++17
 
Hyrje openmp
Hyrje openmpHyrje openmp
Hyrje openmp
 
C++14 reflections
C++14 reflections C++14 reflections
C++14 reflections
 
Java & le pattern matching
Java & le pattern matchingJava & le pattern matching
Java & le pattern matching
 
Тененёв Анатолий, Boost.Asio в алгоритмической торговле
Тененёв Анатолий, Boost.Asio в алгоритмической торговлеТененёв Анатолий, Boost.Asio в алгоритмической торговле
Тененёв Анатолий, Boost.Asio в алгоритмической торговле
 
Librerias de c++
Librerias de c++Librerias de c++
Librerias de c++
 
Monads
MonadsMonads
Monads
 
ECMAscript 2015 aka ES6 : à la découverte du nouveau javascript
ECMAscript 2015 aka ES6 : à la découverte du nouveau javascriptECMAscript 2015 aka ES6 : à la découverte du nouveau javascript
ECMAscript 2015 aka ES6 : à la découverte du nouveau javascript
 
JavaScript
JavaScriptJavaScript
JavaScript
 
Java Thread Cronometro
Java Thread CronometroJava Thread Cronometro
Java Thread Cronometro
 
Tomografi Delay Time Sederhana
Tomografi Delay Time SederhanaTomografi Delay Time Sederhana
Tomografi Delay Time Sederhana
 
EJEMPLOS DESARROLLADOS
EJEMPLOS DESARROLLADOSEJEMPLOS DESARROLLADOS
EJEMPLOS DESARROLLADOS
 
Taller1
Taller1Taller1
Taller1
 
Sobrecarga e Sobrescrita - Preparatório Certificação - OCAJP7 - Aula 2 - F
Sobrecarga e Sobrescrita - Preparatório Certificação - OCAJP7 - Aula 2 - FSobrecarga e Sobrescrita - Preparatório Certificação - OCAJP7 - Aula 2 - F
Sobrecarga e Sobrescrita - Preparatório Certificação - OCAJP7 - Aula 2 - F
 
โปรแกรมย่อยและฟังก์ชั่นมาตรฐาน
โปรแกรมย่อยและฟังก์ชั่นมาตรฐาน โปรแกรมย่อยและฟังก์ชั่นมาตรฐาน
โปรแกรมย่อยและฟังก์ชั่นมาตรฐาน
 

Viewers also liked

The Analysis of Alipay
The Analysis of AlipayThe Analysis of Alipay
The Analysis of Alipayabby0531
 
Alipay brings mobile wallet to china's stores
Alipay  brings mobile wallet to china's storesAlipay  brings mobile wallet to china's stores
Alipay brings mobile wallet to china's storesL'Atelier BNP Paribas
 
Web encoding 元则
Web encoding 元则Web encoding 元则
Web encoding 元则Alipay
 
Html&Browser
Html&BrowserHtml&Browser
Html&BrowserAlipay
 
Css101
Css101Css101
Css101Alipay
 
Javascript 基础
Javascript 基础Javascript 基础
Javascript 基础Alipay
 
Privy: prepare your ecommerce site for black friday and cyber monday
Privy: prepare your ecommerce site for black friday and cyber mondayPrivy: prepare your ecommerce site for black friday and cyber monday
Privy: prepare your ecommerce site for black friday and cyber mondayPrivy
 
How Mobile Drives In-Store Sales
How Mobile Drives In-Store SalesHow Mobile Drives In-Store Sales
How Mobile Drives In-Store SalesPrivy
 
Linkable networks
Linkable networks Linkable networks
Linkable networks MarkBees
 
How to Drive In-Store Sales in Today’s Search Marketing World - RevTrax and ...
How to Drive In-Store Sales in Today’s Search Marketing World - RevTrax and ...How to Drive In-Store Sales in Today’s Search Marketing World - RevTrax and ...
How to Drive In-Store Sales in Today’s Search Marketing World - RevTrax and ...Kenshoo
 
Mobile Coupons a 2016 Report
Mobile Coupons a 2016 ReportMobile Coupons a 2016 Report
Mobile Coupons a 2016 ReportAnup Deshmukh
 
Alipay business analysis
Alipay   business analysisAlipay   business analysis
Alipay business analysisZhuo Dai
 
How Chinese Consumers Make Payment Online
How Chinese Consumers Make Payment OnlineHow Chinese Consumers Make Payment Online
How Chinese Consumers Make Payment OnlineRocky Fu
 
Design Thinking: The one thing that will transform the way you think
Design Thinking: The one thing that will transform the way you thinkDesign Thinking: The one thing that will transform the way you think
Design Thinking: The one thing that will transform the way you thinkDigital Surgeons
 
5. Methods of Payment in International Trade/Export and Import Finance
5. Methods of Payment in International Trade/Export and Import Finance5. Methods of Payment in International Trade/Export and Import Finance
5. Methods of Payment in International Trade/Export and Import FinanceCharu Rastogi
 

Viewers also liked (17)

The Analysis of Alipay
The Analysis of AlipayThe Analysis of Alipay
The Analysis of Alipay
 
Alipay brings mobile wallet to china's stores
Alipay  brings mobile wallet to china's storesAlipay  brings mobile wallet to china's stores
Alipay brings mobile wallet to china's stores
 
Web encoding 元则
Web encoding 元则Web encoding 元则
Web encoding 元则
 
Html&Browser
Html&BrowserHtml&Browser
Html&Browser
 
Css101
Css101Css101
Css101
 
Javascript 基础
Javascript 基础Javascript 基础
Javascript 基础
 
Privy: prepare your ecommerce site for black friday and cyber monday
Privy: prepare your ecommerce site for black friday and cyber mondayPrivy: prepare your ecommerce site for black friday and cyber monday
Privy: prepare your ecommerce site for black friday and cyber monday
 
How Mobile Drives In-Store Sales
How Mobile Drives In-Store SalesHow Mobile Drives In-Store Sales
How Mobile Drives In-Store Sales
 
Linkable networks
Linkable networks Linkable networks
Linkable networks
 
Wechat wallet
Wechat walletWechat wallet
Wechat wallet
 
How to Drive In-Store Sales in Today’s Search Marketing World - RevTrax and ...
How to Drive In-Store Sales in Today’s Search Marketing World - RevTrax and ...How to Drive In-Store Sales in Today’s Search Marketing World - RevTrax and ...
How to Drive In-Store Sales in Today’s Search Marketing World - RevTrax and ...
 
Mobile Coupons a 2016 Report
Mobile Coupons a 2016 ReportMobile Coupons a 2016 Report
Mobile Coupons a 2016 Report
 
Alipay business analysis
Alipay   business analysisAlipay   business analysis
Alipay business analysis
 
How Chinese Consumers Make Payment Online
How Chinese Consumers Make Payment OnlineHow Chinese Consumers Make Payment Online
How Chinese Consumers Make Payment Online
 
WeChat Impact Report 2016
WeChat Impact Report 2016WeChat Impact Report 2016
WeChat Impact Report 2016
 
Design Thinking: The one thing that will transform the way you think
Design Thinking: The one thing that will transform the way you thinkDesign Thinking: The one thing that will transform the way you think
Design Thinking: The one thing that will transform the way you think
 
5. Methods of Payment in International Trade/Export and Import Finance
5. Methods of Payment in International Trade/Export and Import Finance5. Methods of Payment in International Trade/Export and Import Finance
5. Methods of Payment in International Trade/Export and Import Finance
 

More from Alipay

学会站在设计的角度做开发
学会站在设计的角度做开发学会站在设计的角度做开发
学会站在设计的角度做开发Alipay
 
洞察、创造与想象
洞察、创造与想象洞察、创造与想象
洞察、创造与想象Alipay
 
seaJs—不仅仅是脚本加载器
seaJs—不仅仅是脚本加载器seaJs—不仅仅是脚本加载器
seaJs—不仅仅是脚本加载器Alipay
 
从小书签到浏览器扩展的应用
从小书签到浏览器扩展的应用从小书签到浏览器扩展的应用
从小书签到浏览器扩展的应用Alipay
 
谈谈Javascript设计
谈谈Javascript设计谈谈Javascript设计
谈谈Javascript设计Alipay
 
行为化体验度量
行为化体验度量行为化体验度量
行为化体验度量Alipay
 
Html基础
Html基础Html基础
Html基础Alipay
 
前端本地环境初探
前端本地环境初探前端本地环境初探
前端本地环境初探Alipay
 
前端本地环境初探
前端本地环境初探前端本地环境初探
前端本地环境初探Alipay
 
重构用户体验
重构用户体验重构用户体验
重构用户体验Alipay
 
Js in js
Js in jsJs in js
Js in jsAlipay
 

More from Alipay (11)

学会站在设计的角度做开发
学会站在设计的角度做开发学会站在设计的角度做开发
学会站在设计的角度做开发
 
洞察、创造与想象
洞察、创造与想象洞察、创造与想象
洞察、创造与想象
 
seaJs—不仅仅是脚本加载器
seaJs—不仅仅是脚本加载器seaJs—不仅仅是脚本加载器
seaJs—不仅仅是脚本加载器
 
从小书签到浏览器扩展的应用
从小书签到浏览器扩展的应用从小书签到浏览器扩展的应用
从小书签到浏览器扩展的应用
 
谈谈Javascript设计
谈谈Javascript设计谈谈Javascript设计
谈谈Javascript设计
 
行为化体验度量
行为化体验度量行为化体验度量
行为化体验度量
 
Html基础
Html基础Html基础
Html基础
 
前端本地环境初探
前端本地环境初探前端本地环境初探
前端本地环境初探
 
前端本地环境初探
前端本地环境初探前端本地环境初探
前端本地环境初探
 
重构用户体验
重构用户体验重构用户体验
重构用户体验
 
Js in js
Js in jsJs in js
Js in js
 

Javascrpt arale

  • 2.
  • 3. web 术 职责
  • 4. web 术 职责 JavaScript语
  • 5. web 术 职责 JavaScript语 选择 DOM
  • 6. web 术 职责 JavaScript语 选择 DOM Arale
  • 7. web 术 职责
  • 8.
  • 9.
  • 10. 职责 MVC HTML M CSS 样 V JavaScript 为 C
  • 11. 职责 MVC HTML M CSS 样 V JavaScript 为 C
  • 12. 职责 MVC HTML M CSS 样 V JavaScript 为 C
  • 13. web 术 职责 JavaScript语 选择 DOM Arale
  • 15.
  • 16. 语 变
  • 17. 变 时 number, string, object, boolean, null, undefined
  • 18. 变 时 number, string, object, boolean, null, undefined
  • 19.
  • 20. number, string, boolean VS. Number, String, Boolean
  • 21. number, string, boolean 传递 VS. Number, String, Boolean
  • 22. number, string, boolean 传递 VS. Number, String, Boolean 对 传递
  • 23. number, string, boolean 传递 VS. Number, String, Boolean 对 传递 undefined VS. null
  • 24. number, string, boolean 传递 VS. Number, String, Boolean 对 传递 undefined 变 创 赋 应该 传递 VS. null
  • 25. number, string, boolean 传递 VS. Number, String, Boolean 对 传递 undefined 变 创 赋 应该 传递 VS. null 传递
  • 26.
  • 27.
  • 28. var x = new Boolean(false); if (x) { alert('hi'); // Shows 'hi'. }
  • 29. var x = new Boolean(false); if (x) { alert('hi'); // Shows 'hi'. } var x = Boolean(0); if (x) { alert('hi'); // This will never be alerted. } typeof Boolean(0) == 'boolean'; typeof new Boolean(0) == 'object';
  • 30.
  • 31. function f1(x) { var a = 1; if(x) { var b = 2; } function f2() { var c = 3; } console.log(a); console.log(b); console.log(c); } f1(4);
  • 32. function f1(x) { var a = 1; 1 if(x) { 2 var b = 2; undefined } function f2() { var c = 3; } console.log(a); console.log(b); console.log(c); } f1(4);
  • 33. JavaS cript
  • 34.
  • 35. if (x) { function foo() {} }
  • 36. if (x) { function foo() {} }
  • 37. if (x) { if (x) { function foo() {}     var foo = function() {} } }
  • 39. expression & literal function fn() { console.log(f1); var f1 = function() { console.log("f1") } console.log(f1); console.log(f2); function f2() { } console.log(f2); var f2 = function() { console.log("f3"); } f2(); } fn()
  • 40. expression & literal function fn() { console.log(f1); var f1 = function() { console.log("f1") } console.log(f1); console.log(f2); function f2() { } console.log(f2); var f2 = function() { console.log("f3"); } f2(); } fn()
  • 41. expression & literal function fn() { console.log(f1); var f1 = function() { console.log("f1") 结 } console.log(f1); null function console.log(f2); function f2() { function } function console.log(f2); f3 var f2 = function() { console.log("f3"); } f2(); } fn()
  • 42.
  • 44. 达为 变
  • 45. 达为 变 储 结 储
  • 46. 达为 变 储 结 储
  • 47. 达为 变 储 结 储 为 结
  • 48.
  • 49. prototype
  • 50. prototype function Circle(x, y, z) { this.x = x; this.y = y; this.r = r; this.getR = function() { return this.r;}; } //instance method Circle.prototype.area = function() { return this.r * this.r * 3.14159; } var c = new Circle(0, 0, 2); alert(c.area());
  • 51. prototype function Circle(x, y, z) { this.x = x; this.y = y; getR Vs. area this.r = r; this.getR = function() { return this.r;}; } //instance method Circle.prototype.area = function() { return this.r * this.r * 3.14159; } var c = new Circle(0, 0, 2); alert(c.area());
  • 52. prototype function Circle(x, y, z) { this.x = x; this.y = y; getR Vs. area this.r = r; this.getR = function() { return this.r;}; } //instance method Circle.prototype.area = function() { //static method return this.r * this.r * 3.14159; Circle.getClassName = function() { } return “Circle”; var c = new Circle(0, 0, 2); } alert(c.area());
  • 53. prototype function Circle(x, y, z) { this.x = x; this.y = y; getR Vs. area this.r = r; this.getR = function() { return this.r;}; } //instance method Circle.prototype.area = function() { //static method return this.r * this.r * 3.14159; Circle.getClassName = function() { } return “Circle”; var c = new Circle(0, 0, 2); } alert(c.area()); prototype 对 实 对 这 为 础
  • 54.
  • 55. 继 function ClassA(sColor) { this.color = sColor; } ClassA.prototype.sayColor = function () { alert(this.color); }; function ClassB(sColor, sName) { ClassA.call(this, sColor); this.name = sName; } ClassB.prototype = new ClassA(); ClassB.prototype.sayName = function () { alert(this.name); };
  • 56. 继 function ClassA(sColor) { this.color = sColor; } ClassA.prototype.sayColor = function () { }; alert(this.color); 对 function ClassB(sColor, sName) { ClassA.call(this, sColor); this.name = sName; } ClassB.prototype = new ClassA(); ClassB.prototype.sayName = function () { alert(this.name); };
  • 57. 继 function ClassA(sColor) { this.color = sColor; } ClassA.prototype.sayColor = function () { }; alert(this.color); 对 function ClassB(sColor, sName) { ClassA.call(this, sColor); this.name = sName; } ClassB.prototype = new ClassA(); 链 ClassB.prototype.sayName = function () { alert(this.name); };
  • 58. 继 function ClassA(sColor) { this.color = sColor; } ClassA.prototype.sayColor = function () { }; alert(this.color); 对 function ClassB(sColor, sName) { ClassA.call(this, sColor); this.name = sName; } ClassB.prototype = new ClassA(); 链 ClassB.prototype.sayName = function () { alert(this.name); };
  • 59. 对 + 链 function ClassA(sColor) { this.color = sColor; } ClassA.prototype.sayColor = function () { alert(this.color); }; function ClassB(sColor, sName) { ClassA.call(this, sColor); this.name = sName; } ClassB.prototype = new ClassA(); ClassB.prototype.sayName = function () { alert(this.name); };
  • 60.
  • 61. 编 严 调
  • 62. 编 严 调 闭 给 变 环 变 scope chain
  • 63. var sMessage = "hello world"; function sayHelloWorld() { alert(sMessage); 编 严 } 调 sayHelloWorld(); 闭 给 变 环 变 scope chain
  • 64. var sMessage = "hello world"; function sayHelloWorld() { alert(sMessage); 编 严 } 调 sayHelloWorld(); var iBaseNum = 10; 闭 给 function addNum(iNum1, iNum2) { function doAdd() { 变 环 return iNum1 + iNum2 + iBaseNum; 变 } return doAdd(); scope chain }
  • 65. var sMessage = "hello world"; function sayHelloWorld() { alert(sMessage); 编 严 } 调 sayHelloWorld(); var iBaseNum = 10; 闭 给 function addNum(iNum1, iNum2) { function doAdd() { 变 环 return iNum1 + iNum2 + iBaseNum; 变 } return doAdd(); scope chain } 简单 说 闭 义 变
  • 66. 驱动
  • 67. 驱动
  • 68. 驱动
  • 69. 驱动 编 <button id=”btn” onclick=”alert(‘button clicked!’);”>Click Me!</button>
  • 70. 驱动 编 <button id=”btn” onclick=”alert(‘button clicked!’);”>Click Me!</button> var btn = document.getElementById(‘btn’); btn.onclick = function() { alert(“button clicked”); }
  • 71. 驱动 编 <button id=”btn” onclick=”alert(‘button clicked!’);”>Click Me!</button> var btn = document.getElementById(‘btn’); btn.onclick = function() { alert(“button clicked”); } var btn = document.getElementById(‘btn’); if(window.addEventListener) { btn.addEventListener(‘click’, function() {alert(1);}, false); } else { btn.attachEvent(‘onclick’, function() {alert(1);}); }
  • 72. 驱动 编 <button id=”btn” onclick=”alert(‘button clicked!’);”>Click Me!</button> var btn = document.getElementById(‘btn’); btn.onclick = function() { alert(“button clicked”); } var btn = document.getElementById(‘btn’); if(window.addEventListener) { btn.addEventListener(‘click’, function() {alert(1);}, false); } else { btn.attachEvent(‘onclick’, function() {alert(1);}); }
  • 73.
  • 74. click submit change keydown load keypress mouseover resize mouseout scroll blur ......
  • 75. web 术 职责 JavaScript语 选择 DOM Arale
  • 76. 选择 DOM
  • 77. DOM
  • 79. DOM Document Object Model HTML XML 编 规 W3C标
  • 80. DOM Document Object Model HTML XML 编 规 W3C标 过JS DOM对 达 页
  • 84. DOM manipulation 创 删 获 /
  • 85. DOM manipulation 创 删 获 / 访问/
  • 86. DOM
  • 87. DOM getElementById removeChild firstChild, lastChild,childNodes replaceChild previousSibling, nextSibling, createElement parentNode getElementsByTagNam createTextNode e insertBefore appendChild innerHTML
  • 88. var newP = document.createElement("p"); var txt = 'Kilroy was here.'; var newT = document.createTextNode(txt); newP.appendChild(newT); var p2 = document.getElementsByTagName('p')[1]; p2.parentNode.replaceChild(newP,p2);
  • 89. 选择 /selector
  • 90. 选择 /selector css选择 sizzle
  • 91. web 术 职责 JavaScript语 选择 DOM Arale
  • 92.
  • 93. Arale
  • 94.
  • 95. Arale
  • 96. Arale Js Arale
  • 97. Alice Arale Js Arale
  • 98. Alice Arale Js Arale combo
  • 99. Alice Arale Js maven Arale combo
  • 100. Alice Arale Js maven Arale static server combo
  • 101. Alice Arale Js maven Arale static server combo
  • 102.
  • 104. Hello World! $E.domReady(function(){ $("btn").click(function(e){ alert("Hello Arale!"); }); });
  • 106. Selector id选择 : $(‘id’)
  • 107. Selector id选择 : $(‘id’) Node
  • 108. Selector id选择 : $(‘id’) Node 杂选择 $$(selector)
  • 109. Selector id选择 : $(‘id’) Node 杂选择 $$(selector) 组 组 节 为Node
  • 110. Dom & Node $D —— 态 $Node—— 对 获 实
  • 111. Dom & Node $D —— 态 $Node—— 对 获 实 Dom toDom getPosition setStyle getDocumentWidth getDocumentHeight getViewportWidth getViewportHeight
  • 112. Dom & Node $D —— 态 $Node—— 对 获 实 Node Dom addClass toDom removeClass getPosition attr setStyle inject getDocumentWidth getStyle getDocumentHeight setStyle getViewportWidth next getViewportHeight previous parent query
  • 114. Event——$E $E.domReady(function() { //do something });
  • 115. Event——$E connect disconnect $E.domReady(function() { //do something subscribe }); unsubscribe publish trigger delegate live
  • 116. Event——$E connect disconnect $E.domReady(function() { //do something subscribe }); unsubscribe publish trigger delegate live
  • 119. 组——$A $A([1,2,3,4,5]).each(function(v, i) { console.log(v); }); map & reduce
  • 120. 组——$A $A([1,2,3,4,5]).each(function(v, i) { console.log(v); }); map & reduce each every some map filter
  • 121. 组——$A $A([1,2,3,4,5]).each(function(v, i) { console.log(v); }); map & reduce Others: each clean every remove some combine map erase filter include last
  • 122.
  • 123. 块设计
  • 124. 块设计 combo 务
  • 125. 块设计 combo 务
  • 126. 块设计 combo 务 Loader.use(‘arale.http’, function() { $Ajax.get(‘url’, { success: function() { } }); });
  • 127. A B Loader.use(‘C’, function() { //some code here }) C 载C 块js 时 A B还 载 时 载
  • 128. 块设计 A B Loader.use(‘C’, function() { //some code here }) C 载C 块js 时 A B还 载 时 载
  • 129.
  • 130. 码检
  • 133. 码检 压缩 测试 编码检测
  • 134. 码检 压缩 测试 编码检测 赖 计
  • 135. 码检 压缩 测试 编码检测 赖 计
  • 136. 码检 压缩 测试 编码检测 赖 计
  • 137. 码检 压缩 测试 编码检测 Maven 赖 计
  • 138. 码检 压缩 测试 编码检测 Maven 赖 计
  • 139. http://arale.alipay.net http://arale.alipay.net:3000 发组 http://arale.alipay.net/ wiki/doku.php?id=wigetdevelopment jsdoc规 http://arale.alipay.net/wiki/ doku.php?id=jsdocstandard
  • 140. task JS实现 Array#sort (delegate) Arale demo
  • 141. Q&A

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n
  55. \n
  56. \n
  57. \n
  58. \n
  59. \n
  60. \n
  61. \n
  62. \n
  63. \n
  64. \n
  65. \n
  66. \n
  67. \n
  68. \n
  69. \n
  70. \n
  71. \n
  72. \n
  73. \n
  74. \n
  75. \n
  76. \n
  77. \n
  78. \n
  79. \n
  80. \n
  81. \n
  82. \n
  83. \n
  84. \n
  85. \n
  86. \n
  87. \n
  88. \n
  89. \n
  90. \n
  91. \n
  92. \n
  93. \n
  94. \n
  95. \n
  96. \n
  97. \n
  98. \n
  99. \n
  100. \n
  101. \n
  102. \n
  103. \n
  104. \n
  105. \n
  106. \n
  107. \n
  108. \n
  109. \n
  110. \n
  111. \n
  112. \n
  113. \n
  114. \n
  115. \n
  116. \n
  117. \n
  118. \n
  119. \n
  120. \n
  121. \n
  122. \n
  123. \n
  124. \n
  125. \n
  126. \n
  127. \n
  128. \n
  129. \n
  130. \n
  131. \n
  132. \n
  133. \n
  134. \n
  135. \n