SlideShare uma empresa Scribd logo
1 de 63
Java & Script
JavaScript   Java
,
Java         JavaScript


                          ,
Java   JavaScript
Java + Script
           =
Groovy || JRuby || Scala
Java + Script
    |!=|
 JavaScript
JavaScript is
JavaScript is


JavaScript
+
Code:
new Boolean(true) == true
new Boolean(true) === false
Code:
var a = “”;
if (a) {
    alert(a);
}
• new Boolean(true)   true

• == ===
• if (a) a
•
•
•
•5
     null undefined
•   20

•     true

•     ”hello, world!”

•   [12, 30, true, “hello”]

•   {name: “qingyu”, id: 17300}
• ==    ===

• ===     ==



•              ECMA
Tips

•
•               ===
    ==
Code:
var price = 100;

function doSomething() {

       var doublePrice = price * 2;

       var price = 200;

       var halfPrice = price / 2;

       alert(doublePrice);

       alert(halfPrice);

}

doSomething();

alert(price);
Code:
var color = “red”;

if (true) {

        var color = “blue”;

        alert(color);

}

alert(color);
• var doublePrice = price * 2   var halfPrice
    = price / 2        price



•        color
•
•
•   var   var



•
•
Tips


•
Code:
var a = 0 && true;

var b = true && 2;

var c = 0 || 3;



var cfg = {maxHeight: 200};

var d = cfg.height || cfg.maxHeight;
Code:
//                            0

var check = function(obj) {

      return !!(obj || obj === 0);

};
• &&    ||



• &&    ||



• !!a        a
Tips

•      ||



• !!
Code:
(function() {
    //code here
})();
var fn = function() {
     //code here
};
fn();
var fn = function() {
     //code here
};
fn();
var fn = function() {
     //code here
};
fn();
(function() {
     //code here
}) ();
Code:
var createComparisonFunction = function(propertyName) {

      return function(object1, object2) {

           var value1 = object1[propertyName], value2 = object2[propertyName];

           if (value1 < value2) { return -1; }

           else if (value1 > value2) { return 1; }

           else { return 0; }

      };

}

var fn = createComparisonFunction(‘id’);
•
•
•
•
Tips


•
Code:
var sum = function() {

      var result = 0;

      for(var i = 0, len = arguments.length; i < len; I++) {

          result += arguments[i];

      }

      return result;

};

var total = sum(10, 20, 30);
Code:
function factorial(num) {

      if (num <= 1) {

          return 1;

      } else {

          return num * arguments.callee(num - 1);

      }

}
Code:
function sum(num1, num2) {

      return num1 + num2;

}

function callSum1(num1, num2) {

      return sum.apply(this, [num1, num2]);

}

function callSum2(num1, num2) {

      return sum.call(this, num1, num2);

}
•         Function

•
• arguments

• apply   call
Code:
window.color = “red”;

var obj = {color: “blue”};

function sayColor() {

       alert(this.color);

}

sayColor();

obj.sayColor = sayColor;

obj.sayColor();
Code:
var Dog = function(msg) {

      this.msg = msg;

      this.shout = function() { alert(this.msg); };

      this.waitAndShout = function() {

           setTimeout(function() { alert(this.msg) }, 5000);

      };

};
this
• Java
• this

•        this    window
                this
Code:
var Person = function(name) {

      this.name = name;

      this.sayName = function() {

           alert(this.name);

      };

};

var person1 = new Person(“Jack”);

person1.sayName();
Code:
var Person = function() {};

Person.prototype.name = “Jack”;

Person. prototype.sayName = function() {

      alert(this.name);

};

var person1 = new Person();

person1.sayName();
•
•
Tips


•   Peron
        Person.prototype
Code:
function SuperType() { this.property = true; }

SuperType.prototype.getSuperValue = function() {

      return this.property;

};

function SubType() { this.subProperty = false; }

SubType.prototype = new SuperType();

SubType.prototype.getSubValue = function() {

      return this. subProperty;

};
Code:
var instance = new SubType();

alert(instance.getSuperValue());

alert(instance.getSubValue());



alert(instance instanceof Object);

alert(instance instanceof SuperType);

alert(instance instanceof SubType);
• 1.         ; 2.   SubType.prototype; 3.
       SuperType.prototype;
•
•
•
•
YUI
Thanks

Mais conteúdo relacionado

Mais procurados

Java JIT Optimization Research
Java JIT Optimization Research Java JIT Optimization Research
Java JIT Optimization Research Adam Feldscher
 
Stupid Awesome Python Tricks
Stupid Awesome Python TricksStupid Awesome Python Tricks
Stupid Awesome Python TricksBryan Helmig
 
Learn JavaScript by modeling Rubik Cube
Learn JavaScript by modeling Rubik CubeLearn JavaScript by modeling Rubik Cube
Learn JavaScript by modeling Rubik CubeManoj Kumar
 
[Let'Swift 2019] 실용적인 함수형 프로그래밍 워크샵
[Let'Swift 2019] 실용적인 함수형 프로그래밍 워크샵[Let'Swift 2019] 실용적인 함수형 프로그래밍 워크샵
[Let'Swift 2019] 실용적인 함수형 프로그래밍 워크샵Wanbok Choi
 
C++ L03-Control Structure
C++ L03-Control StructureC++ L03-Control Structure
C++ L03-Control StructureMohammad Shaker
 
Programming with GUTs
Programming with GUTsProgramming with GUTs
Programming with GUTsKevlin Henney
 
미려한 UI/UX를 위한 여정
미려한 UI/UX를 위한 여정미려한 UI/UX를 위한 여정
미려한 UI/UX를 위한 여정SeungChul Kang
 
Ejercicios de programacion
Ejercicios de programacionEjercicios de programacion
Ejercicios de programacionJeff Tu Pechito
 
Programa.eje
Programa.ejePrograma.eje
Programa.ejeguapi387
 
2. Базовый синтаксис Java
2. Базовый синтаксис Java2. Базовый синтаксис Java
2. Базовый синтаксис JavaDEVTYPE
 
Clean Coders Hate What Happens To Your Code When You Use These Enterprise Pro...
Clean Coders Hate What Happens To Your Code When You Use These Enterprise Pro...Clean Coders Hate What Happens To Your Code When You Use These Enterprise Pro...
Clean Coders Hate What Happens To Your Code When You Use These Enterprise Pro...Kevlin Henney
 
C++ Lambda and concurrency
C++ Lambda and concurrencyC++ Lambda and concurrency
C++ Lambda and concurrency명신 김
 
Java binary subtraction
Java binary subtractionJava binary subtraction
Java binary subtractionCharm Sasi
 
Implementation of c string functions
Implementation of c string functionsImplementation of c string functions
Implementation of c string functionsmohamed sikander
 

Mais procurados (20)

Java JIT Optimization Research
Java JIT Optimization Research Java JIT Optimization Research
Java JIT Optimization Research
 
ProgrammingwithGOLang
ProgrammingwithGOLangProgrammingwithGOLang
ProgrammingwithGOLang
 
Stupid Awesome Python Tricks
Stupid Awesome Python TricksStupid Awesome Python Tricks
Stupid Awesome Python Tricks
 
Learn JavaScript by modeling Rubik Cube
Learn JavaScript by modeling Rubik CubeLearn JavaScript by modeling Rubik Cube
Learn JavaScript by modeling Rubik Cube
 
Arrays
ArraysArrays
Arrays
 
[Let'Swift 2019] 실용적인 함수형 프로그래밍 워크샵
[Let'Swift 2019] 실용적인 함수형 프로그래밍 워크샵[Let'Swift 2019] 실용적인 함수형 프로그래밍 워크샵
[Let'Swift 2019] 실용적인 함수형 프로그래밍 워크샵
 
C++ L03-Control Structure
C++ L03-Control StructureC++ L03-Control Structure
C++ L03-Control Structure
 
Programming with GUTs
Programming with GUTsProgramming with GUTs
Programming with GUTs
 
미려한 UI/UX를 위한 여정
미려한 UI/UX를 위한 여정미려한 UI/UX를 위한 여정
미려한 UI/UX를 위한 여정
 
Ejercicios de programacion
Ejercicios de programacionEjercicios de programacion
Ejercicios de programacion
 
Cquestions
Cquestions Cquestions
Cquestions
 
C++ examples &revisions
C++ examples &revisionsC++ examples &revisions
C++ examples &revisions
 
Vcs16
Vcs16Vcs16
Vcs16
 
Programa.eje
Programa.ejePrograma.eje
Programa.eje
 
programming fundamentals
programming fundamentalsprogramming fundamentals
programming fundamentals
 
2. Базовый синтаксис Java
2. Базовый синтаксис Java2. Базовый синтаксис Java
2. Базовый синтаксис Java
 
Clean Coders Hate What Happens To Your Code When You Use These Enterprise Pro...
Clean Coders Hate What Happens To Your Code When You Use These Enterprise Pro...Clean Coders Hate What Happens To Your Code When You Use These Enterprise Pro...
Clean Coders Hate What Happens To Your Code When You Use These Enterprise Pro...
 
C++ Lambda and concurrency
C++ Lambda and concurrencyC++ Lambda and concurrency
C++ Lambda and concurrency
 
Java binary subtraction
Java binary subtractionJava binary subtraction
Java binary subtraction
 
Implementation of c string functions
Implementation of c string functionsImplementation of c string functions
Implementation of c string functions
 

Destaque

【第一季第二期】Dive into javascript event
【第一季第二期】Dive into javascript event【第一季第二期】Dive into javascript event
【第一季第二期】Dive into javascript eventtbosstraining
 
【第一季第一期】前端的深化 by 周杰
【第一季第一期】前端的深化 by 周杰【第一季第一期】前端的深化 by 周杰
【第一季第一期】前端的深化 by 周杰tbosstraining
 
【第一季第一期】开发的前端之痛 by 银环
【第一季第一期】开发的前端之痛 by 银环【第一季第一期】开发的前端之痛 by 银环
【第一季第一期】开发的前端之痛 by 银环tbosstraining
 
【第一季第四期】JavaScript Optimization
【第一季第四期】JavaScript Optimization【第一季第四期】JavaScript Optimization
【第一季第四期】JavaScript Optimizationtbosstraining
 
【第一季第五期】要漂亮很容易!——超简单CSS速成教程
【第一季第五期】要漂亮很容易!——超简单CSS速成教程【第一季第五期】要漂亮很容易!——超简单CSS速成教程
【第一季第五期】要漂亮很容易!——超简单CSS速成教程tbosstraining
 
【第一季•第六期】Ajax & JSONP in Action
【第一季•第六期】Ajax & JSONP in Action【第一季•第六期】Ajax & JSONP in Action
【第一季•第六期】Ajax & JSONP in Actiontbosstraining
 

Destaque (6)

【第一季第二期】Dive into javascript event
【第一季第二期】Dive into javascript event【第一季第二期】Dive into javascript event
【第一季第二期】Dive into javascript event
 
【第一季第一期】前端的深化 by 周杰
【第一季第一期】前端的深化 by 周杰【第一季第一期】前端的深化 by 周杰
【第一季第一期】前端的深化 by 周杰
 
【第一季第一期】开发的前端之痛 by 银环
【第一季第一期】开发的前端之痛 by 银环【第一季第一期】开发的前端之痛 by 银环
【第一季第一期】开发的前端之痛 by 银环
 
【第一季第四期】JavaScript Optimization
【第一季第四期】JavaScript Optimization【第一季第四期】JavaScript Optimization
【第一季第四期】JavaScript Optimization
 
【第一季第五期】要漂亮很容易!——超简单CSS速成教程
【第一季第五期】要漂亮很容易!——超简单CSS速成教程【第一季第五期】要漂亮很容易!——超简单CSS速成教程
【第一季第五期】要漂亮很容易!——超简单CSS速成教程
 
【第一季•第六期】Ajax & JSONP in Action
【第一季•第六期】Ajax & JSONP in Action【第一季•第六期】Ajax & JSONP in Action
【第一季•第六期】Ajax & JSONP in Action
 

Semelhante a 【第一季第三期】Thinking in Javascript & OO in Javascript - 清羽

JavaScript - i och utanför webbläsaren (2010-03-03)
JavaScript - i och utanför webbläsaren (2010-03-03)JavaScript - i och utanför webbläsaren (2010-03-03)
JavaScript - i och utanför webbläsaren (2010-03-03)Anders Jönsson
 
ECMAScript 6 major changes
ECMAScript 6 major changesECMAScript 6 major changes
ECMAScript 6 major changeshayato
 
OO JS for AS3 Devs
OO JS for AS3 DevsOO JS for AS3 Devs
OO JS for AS3 DevsJason Hanson
 
Paradigmas de Linguagens de Programacao - Aula #4
Paradigmas de Linguagens de Programacao - Aula #4Paradigmas de Linguagens de Programacao - Aula #4
Paradigmas de Linguagens de Programacao - Aula #4Ismar Silveira
 
Damn Fine CoffeeScript
Damn Fine CoffeeScriptDamn Fine CoffeeScript
Damn Fine CoffeeScriptniklal
 
CodiLime Tech Talk - Grzegorz Rozdzialik: What the java script
CodiLime Tech Talk - Grzegorz Rozdzialik: What the java scriptCodiLime Tech Talk - Grzegorz Rozdzialik: What the java script
CodiLime Tech Talk - Grzegorz Rozdzialik: What the java scriptCodiLime
 
Front end fundamentals session 1: javascript core
Front end fundamentals session 1: javascript coreFront end fundamentals session 1: javascript core
Front end fundamentals session 1: javascript coreWeb Zhao
 
Introduction to web programming for java and c# programmers by @drpicox
Introduction to web programming for java and c# programmers by @drpicoxIntroduction to web programming for java and c# programmers by @drpicox
Introduction to web programming for java and c# programmers by @drpicoxDavid Rodenas
 
Groovy grails types, operators, objects
Groovy grails types, operators, objectsGroovy grails types, operators, objects
Groovy grails types, operators, objectsHusain Dalal
 
Javascript Styles and some tips
Javascript Styles and some tipsJavascript Styles and some tips
Javascript Styles and some tipsVítor Baptista
 
From clever code to better code
From clever code to better codeFrom clever code to better code
From clever code to better codeDror Helper
 
Hypercritical C++ Code Review
Hypercritical C++ Code ReviewHypercritical C++ Code Review
Hypercritical C++ Code ReviewAndrey Karpov
 

Semelhante a 【第一季第三期】Thinking in Javascript & OO in Javascript - 清羽 (20)

CoffeeScript
CoffeeScriptCoffeeScript
CoffeeScript
 
JavaScript - i och utanför webbläsaren (2010-03-03)
JavaScript - i och utanför webbläsaren (2010-03-03)JavaScript - i och utanför webbläsaren (2010-03-03)
JavaScript - i och utanför webbläsaren (2010-03-03)
 
ECMAScript 6 major changes
ECMAScript 6 major changesECMAScript 6 major changes
ECMAScript 6 major changes
 
OO JS for AS3 Devs
OO JS for AS3 DevsOO JS for AS3 Devs
OO JS for AS3 Devs
 
Paradigmas de Linguagens de Programacao - Aula #4
Paradigmas de Linguagens de Programacao - Aula #4Paradigmas de Linguagens de Programacao - Aula #4
Paradigmas de Linguagens de Programacao - Aula #4
 
Introduction to Groovy
Introduction to GroovyIntroduction to Groovy
Introduction to Groovy
 
ES6, WTF?
ES6, WTF?ES6, WTF?
ES6, WTF?
 
Groovy
GroovyGroovy
Groovy
 
Damn Fine CoffeeScript
Damn Fine CoffeeScriptDamn Fine CoffeeScript
Damn Fine CoffeeScript
 
CodiLime Tech Talk - Grzegorz Rozdzialik: What the java script
CodiLime Tech Talk - Grzegorz Rozdzialik: What the java scriptCodiLime Tech Talk - Grzegorz Rozdzialik: What the java script
CodiLime Tech Talk - Grzegorz Rozdzialik: What the java script
 
Front end fundamentals session 1: javascript core
Front end fundamentals session 1: javascript coreFront end fundamentals session 1: javascript core
Front end fundamentals session 1: javascript core
 
Typescript barcelona
Typescript barcelonaTypescript barcelona
Typescript barcelona
 
Introduction to web programming for java and c# programmers by @drpicox
Introduction to web programming for java and c# programmers by @drpicoxIntroduction to web programming for java and c# programmers by @drpicox
Introduction to web programming for java and c# programmers by @drpicox
 
Einführung in TypeScript
Einführung in TypeScriptEinführung in TypeScript
Einführung in TypeScript
 
Groovy grails types, operators, objects
Groovy grails types, operators, objectsGroovy grails types, operators, objects
Groovy grails types, operators, objects
 
Javascript Styles and some tips
Javascript Styles and some tipsJavascript Styles and some tips
Javascript Styles and some tips
 
Short intro to ECMAScript
Short intro to ECMAScriptShort intro to ECMAScript
Short intro to ECMAScript
 
From clever code to better code
From clever code to better codeFrom clever code to better code
From clever code to better code
 
Java Script Workshop
Java Script WorkshopJava Script Workshop
Java Script Workshop
 
Hypercritical C++ Code Review
Hypercritical C++ Code ReviewHypercritical C++ Code Review
Hypercritical C++ Code Review
 

Último

MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbuapidays
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 

Último (20)

MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 

【第一季第三期】Thinking in Javascript & OO in Javascript - 清羽

  • 2. JavaScript Java
  • 3.
  • 4.
  • 5. , Java JavaScript , Java JavaScript
  • 6. Java + Script = Groovy || JRuby || Scala
  • 7. Java + Script |!=| JavaScript
  • 10.
  • 11.
  • 12. +
  • 13. Code: new Boolean(true) == true new Boolean(true) === false
  • 14. Code: var a = “”; if (a) { alert(a); }
  • 15. • new Boolean(true) true • == === • if (a) a
  • 17. •5 null undefined
  • 18. 20 • true • ”hello, world!” • [12, 30, true, “hello”] • {name: “qingyu”, id: 17300}
  • 19.
  • 20. • == === • === == • ECMA
  • 21. Tips • • === ==
  • 22. Code: var price = 100; function doSomething() { var doublePrice = price * 2; var price = 200; var halfPrice = price / 2; alert(doublePrice); alert(halfPrice); } doSomething(); alert(price);
  • 23. Code: var color = “red”; if (true) { var color = “blue”; alert(color); } alert(color);
  • 24. • var doublePrice = price * 2 var halfPrice = price / 2 price • color
  • 26. var var •
  • 27.
  • 29. Code: var a = 0 && true; var b = true && 2; var c = 0 || 3; var cfg = {maxHeight: 200}; var d = cfg.height || cfg.maxHeight;
  • 30. Code: // 0 var check = function(obj) { return !!(obj || obj === 0); };
  • 31. • && || • && || • !!a a
  • 32. Tips • || • !!
  • 33. Code: (function() { //code here })();
  • 34.
  • 35. var fn = function() { //code here }; fn();
  • 36. var fn = function() { //code here }; fn();
  • 37. var fn = function() { //code here }; fn();
  • 38. (function() { //code here }) ();
  • 39. Code: var createComparisonFunction = function(propertyName) { return function(object1, object2) { var value1 = object1[propertyName], value2 = object2[propertyName]; if (value1 < value2) { return -1; } else if (value1 > value2) { return 1; } else { return 0; } }; } var fn = createComparisonFunction(‘id’);
  • 41.
  • 42.
  • 44. Code: var sum = function() { var result = 0; for(var i = 0, len = arguments.length; i < len; I++) { result += arguments[i]; } return result; }; var total = sum(10, 20, 30);
  • 45. Code: function factorial(num) { if (num <= 1) { return 1; } else { return num * arguments.callee(num - 1); } }
  • 46. Code: function sum(num1, num2) { return num1 + num2; } function callSum1(num1, num2) { return sum.apply(this, [num1, num2]); } function callSum2(num1, num2) { return sum.call(this, num1, num2); }
  • 47. Function • • arguments • apply call
  • 48. Code: window.color = “red”; var obj = {color: “blue”}; function sayColor() { alert(this.color); } sayColor(); obj.sayColor = sayColor; obj.sayColor();
  • 49. Code: var Dog = function(msg) { this.msg = msg; this.shout = function() { alert(this.msg); }; this.waitAndShout = function() { setTimeout(function() { alert(this.msg) }, 5000); }; };
  • 50. this • Java • this • this window this
  • 51. Code: var Person = function(name) { this.name = name; this.sayName = function() { alert(this.name); }; }; var person1 = new Person(“Jack”); person1.sayName();
  • 52. Code: var Person = function() {}; Person.prototype.name = “Jack”; Person. prototype.sayName = function() { alert(this.name); }; var person1 = new Person(); person1.sayName();
  • 54.
  • 55. Tips • Peron Person.prototype
  • 56. Code: function SuperType() { this.property = true; } SuperType.prototype.getSuperValue = function() { return this.property; }; function SubType() { this.subProperty = false; } SubType.prototype = new SuperType(); SubType.prototype.getSubValue = function() { return this. subProperty; };
  • 57. Code: var instance = new SubType(); alert(instance.getSuperValue()); alert(instance.getSubValue()); alert(instance instanceof Object); alert(instance instanceof SuperType); alert(instance instanceof SubType);
  • 58. • 1. ; 2. SubType.prototype; 3. SuperType.prototype;
  • 59.
  • 61. YUI
  • 62.

Notas do Editor