SlideShare a Scribd company logo
obvious secrets of

                           JavaScript



Monday, 21 December 2009
Monday, 21 December 2009
E very object (including host       objects) must implement the
                              e)) and ((Class)) propertie      s and the ((Get)), ((Put)),
                   ((Prototyp
                              t)), ((HasProperty)), ((Dele      te)), and ((DefaultValue))
                   ((CanPu
                              . (Note, however, that the ((D       efaultValue)) method may,
                   methods                                                  exception.) The value
                    for some objects    , simply throw a TypeError
                               Prototype)) property must be      either an object or null, and
                    of the ((
                               Prototype)) chain must have       finite length (that is, starting
                    every ((
                                y object, recursively access     ing the ((Prototype)) property
                     from an
                               entually lead to a null val         ue). Whether or not a native
                     must ev
                               an have a host object as its       ((Prototype)) depends on the
                     object c
                     implementation.
                          The value      of the ((Class)) property
                      is defined by        this specification for every
                      kind of built-i   n object. The value of the
                       ((Class)) prop    erty of a host object may
                       be any value     , even a value used by
Monday, 21 December 2009
E very object (including host       objects) must implement the
                              e)) and ((Class)) propertie      s and the ((Get)), ((Put)),
                   ((Prototyp
                              t)), ((HasProperty)), ((Dele      te)), and ((DefaultValue))
                   ((CanPu
                              . (Note, however, that the ((D       efaultValue)) method may,
                   methods                                                  exception.) The value
                    for some objects    , simply throw a TypeError
                               Prototype)) property must be      either an object or null, and
                    of the ((
                               Prototype)) chain must have       finite length (that is, starting
                    every ((
                                                                 ing the ((Prototype)) property
                     from an       It is a bit “cryptic”
                                y object, recursively access
                               entually lead to a null val         ue). Whether or not a native
                     must ev
                               an have a host object as its       ((Prototype)) depends on the
                     object c
                     implementation.
                          The value      of the ((Class)) property
                      is defined by        this specification for every
                      kind of built-i   n object. The value of the
                       ((Class)) prop    erty of a host object may
                       be any value     , even a value used by
Monday, 21 December 2009
Types




Monday, 21 December 2009
number      string

                           boolean    object

                             null    undefined



Monday, 21 December 2009
typeof
                           undefined      "undefined"

                              null         "object"

                            number         "number"

                           boolean         "boolean"

                             string        "string"

                            object         "object"


Monday, 21 December 2009
to Number
                           undefined         NaN

                              null            0

                            number            —

                           boolean     true→1, false→0

                             string        parsing

                            object       .valueOf()


Monday, 21 December 2009
to String
                           undefined       "undefined"

                              null           "null"

                            number             "5"

                           boolean           "true"

                             string              —

                            object         .toString()


Monday, 21 December 2009
to Boolean
                           undefined      FALSE

                              null        FALSE

                            number     0||NaN→false

                           boolean          —

                             string      ""→false

                            object         TRUE


Monday, 21 December 2009
to Object
                           undefined      exception!

                              null        exception!

                            number       new Number(5)

                           boolean     new Boolean(true)

                             string    new String("js")

                            object          object


Monday, 21 December 2009
5 + 4 + "px"
               "$" + 1 + 2
               "4" / "2"
               "$" + 1 - 2
               "web".length
               typeof 5
               typeof "5"
               typeof {key: value}
               typeof null
               typeof undefined
               typeof [1, 2, 3]
               typeof (4 - "px")
               +!{}[0]



Monday, 21 December 2009
5 + 4 + "px"          "9px"
               "$" + 1 + 2           "$12"
               "4" / "2"             2
               "$" + 1 - 2           NaN
               "web".length          3
               typeof 5              "number"
               typeof "5"            "string"
               typeof {key: value}   "object"
               typeof null           "object"
               typeof undefined      "undefined"
               typeof [1, 2, 3]      "object"
               typeof (4 - "px")     "number"
               +!{}[0]               1



Monday, 21 December 2009
Object Properties




Monday, 21 December 2009
for in




Monday, 21 December 2009
var a = {
                 x: 12,
                 y: 23,
                 r: 10,
                 draw: function () {/*...*/}
             };


             for (var property in a) {
                 alert("a." + property + " = " +
             a[property]);
             }




Monday, 21 December 2009
var a = {
                 x: 12,
                 y: 23,
                 r: 10,
                 draw: function () {/*...*/}
             };


             for (var property in a) {
                 alert("a." + property + " = " +
             a[property]);
             }




Monday, 21 December 2009
ReadOnly    DontEnum

                           DontDelete    Internal




Monday, 21 December 2009
Function




Monday, 21 December 2009
var y = 1;
             function x() {
                 var y = 2;
                 return ++y;
             }

             var z = function () {
                 return ++y;
             };




Monday, 21 December 2009
function x() {
                 var y = 2;
                 return function () {
                     return ++y;
                 };
             }

             var a = x();
             a();
             a();




Monday, 21 December 2009
typeof function (){} == "function"




Monday, 21 December 2009
Arguments




Monday, 21 December 2009
function add(a, b) {
                 return a + b;
             }

             add(4, 5); // = 9
             add(4, 5, 6, 7, 8, 9) // = 39

             function add() {
                 var sum = 0;
                 for (var i = 0, ii = arguments.length; i <
             ii; i++) {
                     sum +=+ arguments[i];
                 }
                 return sum;
             }


Monday, 21 December 2009
Scope, Context & “this”




Monday, 21 December 2009
function is(it) {
                 alert(this + " is " + it);
             }

             is("global");

             is.call(5, "number");

             is.apply("A", ["string"]);

             alert.is = is;

             alert.is("function");



Monday, 21 December 2009
Variable declaration




Monday, 21 December 2009
alert(b);
     1       b = 1;

             alert(a);
     2       var a = 1;

             (function () {
     3           var x = 1;
             })();
             alert(x);

             (function () {
     4           y = 1;
             })();
             alert(y);




Monday, 21 December 2009
Function declaration




Monday, 21 December 2009
function x(a) {
     1           return a && x(--a);
             }

             var x = function (a) {
     2           return a && x(--a);
             };

             setTimeout(function (a) {
     3           return a && arguments.callee(--a);
             }, 1000);

             var x = function y(a) {
     4           return a && y(--a);
             };

             setTimeout(function y(a) {
     5           return a && y(--a);
             }, 1000);



Monday, 21 December 2009
Array declaration




Monday, 21 December 2009
var a = new Array;

             var a = new Array(3);

             var a = [];

             var a = [undefined, undefined, undefined];

             var a = [1, 2, 3, 4];




Monday, 21 December 2009
Object declaration (JSON)




Monday, 21 December 2009
var a = new Object;

             var a = {};

             var a = {x: 10, y: 15};

             var a = {
                 x: 10,
                 name: "object",
                 "font-style": "italic",
                 getHeight: function () {/*...*/},
                 points: [1, 2, 3],
                 child: {x: 10, y: 15}
             };



Monday, 21 December 2009
OOP




Monday, 21 December 2009
Object Owns Prototype




Monday, 21 December 2009
var mouse = {
     1           name: "Mike",
                 voice: function () { alert("Squik!"); }
             };

             var o = new Object;
     2       o.name = "Mike";
             o.voice = function () { alert("Squik!"); };

             var O = function () {
     3           this.name = "Mike";
                 this.voice = function () { alert("Squik!"); };
             };
             var o = new O;

             var O = function () {};
     4       O.prototype.name = "Mike";
             O.prototype.voice = function () { alert("Squik!"); };
             var o = new O;



Monday, 21 December 2009
Inheritance




Monday, 21 December 2009
Delegation




Monday, 21 December 2009
Classic Model


                                         Class




                                                    Object
                                         Class




                           Object       Object      Object




Monday, 21 December 2009
Prototypal Model




                                                       Object




                           Object         Object       Object




Monday, 21 December 2009
var A = function () {};



                                1   A




Monday, 21 December 2009
var A = function () {};   x: 5
      A.prototype.x = 5;


                                 1     A




Monday, 21 December 2009
var A = function () {};   x: 5
      A.prototype.x = 5;

      var b = new A;
                                 1         A




                                       b




Monday, 21 December 2009
x: 5
      var A = function () {};   y: 6
      A.prototype.x = 5;

      var b = new A;
      A.prototype.y = 6;         1         A




                                       b




Monday, 21 December 2009
x: 5
      var A = function () {};   y: 6
      A.prototype.x = 5;

      var b = new A;
      A.prototype.y = 6;         1         A
      var c = new A;




                                       b   c




Monday, 21 December 2009
x: 5
      var A = function () {};   y: 6
      A.prototype.x = 5;

      var b = new A;
      A.prototype.y = 6;         1            A
      var c = new A;
      b.z = 7;




                                        b     c


                                       z: 7




Monday, 21 December 2009
x: 5
      var A = function () {};   y: 6
      A.prototype.x = 5;

      var b = new A;
      A.prototype.y = 6;         1            A
      var c = new A;
      b.z = 7;
      c.x = 4;



                                        b      c


                                       z: 7   x: 4




Monday, 21 December 2009
x: 5                 w: 1
      var A = function () {};   y: 6                 u: 2
      A.prototype.x = 5;

      var b = new A;
      A.prototype.y = 6;         1            A       2
      var c = new A;
      b.z = 7;
      c.x = 4;

      A.prototype = {
          w: 1,
          u: 2                          b      c
      };

                                       z: 7   x: 4




Monday, 21 December 2009
x: 5                         w: 1
      var A = function () {};   y: 6                         u: 2
      A.prototype.x = 5;

      var b = new A;
      A.prototype.y = 6;         1            A               2
      var c = new A;
      b.z = 7;
      c.x = 4;
                                                     *
      A.prototype = {
          w: 1,
          u: 2                          b      c         d
      };

      var d = new A;                   z: 7   x: 4       —




Monday, 21 December 2009
x: 5                         w: 1
      var A = function () {};   y: 6                         u: 2
      A.prototype.x = 5;

      var b = new A;
      A.prototype.y = 6;         1            A               2
      var c = new A;
      b.z = 7;
      c.x = 4;
                                                     *
      A.prototype = {
          w: 1,
          u: 2                          b      c         d
      };

      var d = new A;                   z: 7   x: 4       —




Monday, 21 December 2009
Thank You




Monday, 21 December 2009

More Related Content

What's hot

Using Reflections and Automatic Code Generation
Using Reflections and Automatic Code GenerationUsing Reflections and Automatic Code Generation
Using Reflections and Automatic Code Generation
Ivan Dolgushin
 
6.1.1一步一步学repast代码解释
6.1.1一步一步学repast代码解释6.1.1一步一步学repast代码解释
6.1.1一步一步学repast代码解释zhang shuren
 
Google Dart
Google DartGoogle Dart
Google Dart
Eberhard Wolff
 
Objective c
Objective cObjective c
Objective c
ricky_chatur2005
 
Scala 2013 review
Scala 2013 reviewScala 2013 review
Scala 2013 review
Sagie Davidovich
 
Dependency Breaking Techniques
Dependency Breaking TechniquesDependency Breaking Techniques
Dependency Breaking Techniques
hyun soomyung
 
Ajaxworld
AjaxworldAjaxworld
Ajaxworld
deannalagason
 
Coding in Style
Coding in StyleCoding in Style
Coding in Style
scalaconfjp
 
Dynamic C++ ACCU 2013
Dynamic C++ ACCU 2013Dynamic C++ ACCU 2013
Dynamic C++ ACCU 2013
aleks-f
 
오브젝트C(pdf)
오브젝트C(pdf)오브젝트C(pdf)
오브젝트C(pdf)
sunwooindia
 
Mysterious c++
Mysterious c++Mysterious c++
Mysterious c++xprayc
 
57200143 flash-action-script-quickref
57200143 flash-action-script-quickref57200143 flash-action-script-quickref
57200143 flash-action-script-quickrefpritam268
 
Treinamento Qt básico - aula III
Treinamento Qt básico - aula IIITreinamento Qt básico - aula III
Treinamento Qt básico - aula III
Marcelo Barros de Almeida
 
openFrameworks 007 - utils
openFrameworks 007 - utilsopenFrameworks 007 - utils
openFrameworks 007 - utils
roxlu
 
Observer pattern with Stl, boost and qt
Observer pattern with Stl, boost and qtObserver pattern with Stl, boost and qt
Observer pattern with Stl, boost and qt
Daniel Eriksson
 
05 - Qt External Interaction and Graphics
05 - Qt External Interaction and Graphics05 - Qt External Interaction and Graphics
05 - Qt External Interaction and Graphics
Andreas Jakl
 
Clojure And Swing
Clojure And SwingClojure And Swing
Clojure And Swing
Skills Matter
 
响应式编程及框架
响应式编程及框架响应式编程及框架
响应式编程及框架
jeffz
 
scalaliftoff2009.pdf
scalaliftoff2009.pdfscalaliftoff2009.pdf
scalaliftoff2009.pdfHiroshi Ono
 

What's hot (20)

Using Reflections and Automatic Code Generation
Using Reflections and Automatic Code GenerationUsing Reflections and Automatic Code Generation
Using Reflections and Automatic Code Generation
 
6.1.1一步一步学repast代码解释
6.1.1一步一步学repast代码解释6.1.1一步一步学repast代码解释
6.1.1一步一步学repast代码解释
 
Google Dart
Google DartGoogle Dart
Google Dart
 
Objective c
Objective cObjective c
Objective c
 
Scala 2013 review
Scala 2013 reviewScala 2013 review
Scala 2013 review
 
Dependency Breaking Techniques
Dependency Breaking TechniquesDependency Breaking Techniques
Dependency Breaking Techniques
 
Ajaxworld
AjaxworldAjaxworld
Ajaxworld
 
Coding in Style
Coding in StyleCoding in Style
Coding in Style
 
Dynamic C++ ACCU 2013
Dynamic C++ ACCU 2013Dynamic C++ ACCU 2013
Dynamic C++ ACCU 2013
 
tutorial5
tutorial5tutorial5
tutorial5
 
오브젝트C(pdf)
오브젝트C(pdf)오브젝트C(pdf)
오브젝트C(pdf)
 
Mysterious c++
Mysterious c++Mysterious c++
Mysterious c++
 
57200143 flash-action-script-quickref
57200143 flash-action-script-quickref57200143 flash-action-script-quickref
57200143 flash-action-script-quickref
 
Treinamento Qt básico - aula III
Treinamento Qt básico - aula IIITreinamento Qt básico - aula III
Treinamento Qt básico - aula III
 
openFrameworks 007 - utils
openFrameworks 007 - utilsopenFrameworks 007 - utils
openFrameworks 007 - utils
 
Observer pattern with Stl, boost and qt
Observer pattern with Stl, boost and qtObserver pattern with Stl, boost and qt
Observer pattern with Stl, boost and qt
 
05 - Qt External Interaction and Graphics
05 - Qt External Interaction and Graphics05 - Qt External Interaction and Graphics
05 - Qt External Interaction and Graphics
 
Clojure And Swing
Clojure And SwingClojure And Swing
Clojure And Swing
 
响应式编程及框架
响应式编程及框架响应式编程及框架
响应式编程及框架
 
scalaliftoff2009.pdf
scalaliftoff2009.pdfscalaliftoff2009.pdf
scalaliftoff2009.pdf
 

Similar to Obvious Secrets of JavaScript

ぐだ生 Java入門第一回(equals hash code_tostring)
ぐだ生 Java入門第一回(equals hash code_tostring)ぐだ生 Java入門第一回(equals hash code_tostring)
ぐだ生 Java入門第一回(equals hash code_tostring)Makoto Yamazaki
 
Scala Intro
Scala IntroScala Intro
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
 
Functional Programming in C++
Functional Programming in C++Functional Programming in C++
Functional Programming in C++
sankeld
 
GDSC NED Frontend Bootcamp Session 1.pptx
GDSC NED Frontend Bootcamp Session 1.pptxGDSC NED Frontend Bootcamp Session 1.pptx
GDSC NED Frontend Bootcamp Session 1.pptx
Ehtesham46
 
Building DSLs with Xtext - Eclipse Modeling Day 2009
Building DSLs with Xtext - Eclipse Modeling Day 2009Building DSLs with Xtext - Eclipse Modeling Day 2009
Building DSLs with Xtext - Eclipse Modeling Day 2009
Heiko Behrens
 

Similar to Obvious Secrets of JavaScript (9)

Java Script Workshop
Java Script WorkshopJava Script Workshop
Java Script Workshop
 
ECMA 入门
ECMA 入门ECMA 入门
ECMA 入门
 
ぐだ生 Java入門第一回(equals hash code_tostring)
ぐだ生 Java入門第一回(equals hash code_tostring)ぐだ生 Java入門第一回(equals hash code_tostring)
ぐだ生 Java入門第一回(equals hash code_tostring)
 
tutorial5
tutorial5tutorial5
tutorial5
 
Scala Intro
Scala IntroScala Intro
Scala Intro
 
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
 
Functional Programming in C++
Functional Programming in C++Functional Programming in C++
Functional Programming in C++
 
GDSC NED Frontend Bootcamp Session 1.pptx
GDSC NED Frontend Bootcamp Session 1.pptxGDSC NED Frontend Bootcamp Session 1.pptx
GDSC NED Frontend Bootcamp Session 1.pptx
 
Building DSLs with Xtext - Eclipse Modeling Day 2009
Building DSLs with Xtext - Eclipse Modeling Day 2009Building DSLs with Xtext - Eclipse Modeling Day 2009
Building DSLs with Xtext - Eclipse Modeling Day 2009
 

More from Dmitry Baranovskiy

The Origins of Magic
The Origins of MagicThe Origins of Magic
The Origins of Magic
Dmitry Baranovskiy
 
Type Recognition
Type RecognitionType Recognition
Type Recognition
Dmitry Baranovskiy
 
Your JavaScript Library
Your JavaScript LibraryYour JavaScript Library
Your JavaScript Library
Dmitry Baranovskiy
 
Canvas
CanvasCanvas
SVG
SVGSVG
Raphael
RaphaelRaphael
Web Vector Graphics
Web Vector GraphicsWeb Vector Graphics
Web Vector Graphics
Dmitry Baranovskiy
 
Microformats—the hidden treasure
Microformats—the hidden treasureMicroformats—the hidden treasure
Microformats—the hidden treasure
Dmitry Baranovskiy
 
Advanced JavaScript Techniques
Advanced JavaScript TechniquesAdvanced JavaScript Techniques
Advanced JavaScript TechniquesDmitry Baranovskiy
 

More from Dmitry Baranovskiy (14)

JavaScript: enter the dragon
JavaScript: enter the dragonJavaScript: enter the dragon
JavaScript: enter the dragon
 
The Origins of Magic
The Origins of MagicThe Origins of Magic
The Origins of Magic
 
Demystifying Prototypes
Demystifying PrototypesDemystifying Prototypes
Demystifying Prototypes
 
Raphaël
RaphaëlRaphaël
Raphaël
 
Type Recognition
Type RecognitionType Recognition
Type Recognition
 
Raphaël JS Conf
Raphaël JS ConfRaphaël JS Conf
Raphaël JS Conf
 
Your JavaScript Library
Your JavaScript LibraryYour JavaScript Library
Your JavaScript Library
 
Canvas
CanvasCanvas
Canvas
 
SVG
SVGSVG
SVG
 
Raphael
RaphaelRaphael
Raphael
 
Web Vector Graphics
Web Vector GraphicsWeb Vector Graphics
Web Vector Graphics
 
Typography on the Web
Typography on the WebTypography on the Web
Typography on the Web
 
Microformats—the hidden treasure
Microformats—the hidden treasureMicroformats—the hidden treasure
Microformats—the hidden treasure
 
Advanced JavaScript Techniques
Advanced JavaScript TechniquesAdvanced JavaScript Techniques
Advanced JavaScript Techniques
 

Recently uploaded

JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 

Recently uploaded (20)

JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 

Obvious Secrets of JavaScript

  • 1. obvious secrets of JavaScript Monday, 21 December 2009
  • 3. E very object (including host objects) must implement the e)) and ((Class)) propertie s and the ((Get)), ((Put)), ((Prototyp t)), ((HasProperty)), ((Dele te)), and ((DefaultValue)) ((CanPu . (Note, however, that the ((D efaultValue)) method may, methods exception.) The value for some objects , simply throw a TypeError Prototype)) property must be either an object or null, and of the (( Prototype)) chain must have finite length (that is, starting every (( y object, recursively access ing the ((Prototype)) property from an entually lead to a null val ue). Whether or not a native must ev an have a host object as its ((Prototype)) depends on the object c implementation. The value of the ((Class)) property is defined by this specification for every kind of built-i n object. The value of the ((Class)) prop erty of a host object may be any value , even a value used by Monday, 21 December 2009
  • 4. E very object (including host objects) must implement the e)) and ((Class)) propertie s and the ((Get)), ((Put)), ((Prototyp t)), ((HasProperty)), ((Dele te)), and ((DefaultValue)) ((CanPu . (Note, however, that the ((D efaultValue)) method may, methods exception.) The value for some objects , simply throw a TypeError Prototype)) property must be either an object or null, and of the (( Prototype)) chain must have finite length (that is, starting every (( ing the ((Prototype)) property from an It is a bit “cryptic” y object, recursively access entually lead to a null val ue). Whether or not a native must ev an have a host object as its ((Prototype)) depends on the object c implementation. The value of the ((Class)) property is defined by this specification for every kind of built-i n object. The value of the ((Class)) prop erty of a host object may be any value , even a value used by Monday, 21 December 2009
  • 6. number string boolean object null undefined Monday, 21 December 2009
  • 7. typeof undefined "undefined" null "object" number "number" boolean "boolean" string "string" object "object" Monday, 21 December 2009
  • 8. to Number undefined NaN null 0 number — boolean true→1, false→0 string parsing object .valueOf() Monday, 21 December 2009
  • 9. to String undefined "undefined" null "null" number "5" boolean "true" string — object .toString() Monday, 21 December 2009
  • 10. to Boolean undefined FALSE null FALSE number 0||NaN→false boolean — string ""→false object TRUE Monday, 21 December 2009
  • 11. to Object undefined exception! null exception! number new Number(5) boolean new Boolean(true) string new String("js") object object Monday, 21 December 2009
  • 12. 5 + 4 + "px" "$" + 1 + 2 "4" / "2" "$" + 1 - 2 "web".length typeof 5 typeof "5" typeof {key: value} typeof null typeof undefined typeof [1, 2, 3] typeof (4 - "px") +!{}[0] Monday, 21 December 2009
  • 13. 5 + 4 + "px" "9px" "$" + 1 + 2 "$12" "4" / "2" 2 "$" + 1 - 2 NaN "web".length 3 typeof 5 "number" typeof "5" "string" typeof {key: value} "object" typeof null "object" typeof undefined "undefined" typeof [1, 2, 3] "object" typeof (4 - "px") "number" +!{}[0] 1 Monday, 21 December 2009
  • 15. for in Monday, 21 December 2009
  • 16. var a = { x: 12, y: 23, r: 10, draw: function () {/*...*/} }; for (var property in a) { alert("a." + property + " = " + a[property]); } Monday, 21 December 2009
  • 17. var a = { x: 12, y: 23, r: 10, draw: function () {/*...*/} }; for (var property in a) { alert("a." + property + " = " + a[property]); } Monday, 21 December 2009
  • 18. ReadOnly DontEnum DontDelete Internal Monday, 21 December 2009
  • 20. var y = 1; function x() { var y = 2; return ++y; } var z = function () { return ++y; }; Monday, 21 December 2009
  • 21. function x() { var y = 2; return function () { return ++y; }; } var a = x(); a(); a(); Monday, 21 December 2009
  • 22. typeof function (){} == "function" Monday, 21 December 2009
  • 24. function add(a, b) { return a + b; } add(4, 5); // = 9 add(4, 5, 6, 7, 8, 9) // = 39 function add() { var sum = 0; for (var i = 0, ii = arguments.length; i < ii; i++) { sum +=+ arguments[i]; } return sum; } Monday, 21 December 2009
  • 25. Scope, Context & “this” Monday, 21 December 2009
  • 26. function is(it) { alert(this + " is " + it); } is("global"); is.call(5, "number"); is.apply("A", ["string"]); alert.is = is; alert.is("function"); Monday, 21 December 2009
  • 28. alert(b); 1 b = 1; alert(a); 2 var a = 1; (function () { 3 var x = 1; })(); alert(x); (function () { 4 y = 1; })(); alert(y); Monday, 21 December 2009
  • 30. function x(a) { 1 return a && x(--a); } var x = function (a) { 2 return a && x(--a); }; setTimeout(function (a) { 3 return a && arguments.callee(--a); }, 1000); var x = function y(a) { 4 return a && y(--a); }; setTimeout(function y(a) { 5 return a && y(--a); }, 1000); Monday, 21 December 2009
  • 32. var a = new Array; var a = new Array(3); var a = []; var a = [undefined, undefined, undefined]; var a = [1, 2, 3, 4]; Monday, 21 December 2009
  • 34. var a = new Object; var a = {}; var a = {x: 10, y: 15}; var a = { x: 10, name: "object", "font-style": "italic", getHeight: function () {/*...*/}, points: [1, 2, 3], child: {x: 10, y: 15} }; Monday, 21 December 2009
  • 36. Object Owns Prototype Monday, 21 December 2009
  • 37. var mouse = { 1 name: "Mike", voice: function () { alert("Squik!"); } }; var o = new Object; 2 o.name = "Mike"; o.voice = function () { alert("Squik!"); }; var O = function () { 3 this.name = "Mike"; this.voice = function () { alert("Squik!"); }; }; var o = new O; var O = function () {}; 4 O.prototype.name = "Mike"; O.prototype.voice = function () { alert("Squik!"); }; var o = new O; Monday, 21 December 2009
  • 40. Classic Model Class Object Class Object Object Object Monday, 21 December 2009
  • 41. Prototypal Model Object Object Object Object Monday, 21 December 2009
  • 42. var A = function () {}; 1 A Monday, 21 December 2009
  • 43. var A = function () {}; x: 5 A.prototype.x = 5; 1 A Monday, 21 December 2009
  • 44. var A = function () {}; x: 5 A.prototype.x = 5; var b = new A; 1 A b Monday, 21 December 2009
  • 45. x: 5 var A = function () {}; y: 6 A.prototype.x = 5; var b = new A; A.prototype.y = 6; 1 A b Monday, 21 December 2009
  • 46. x: 5 var A = function () {}; y: 6 A.prototype.x = 5; var b = new A; A.prototype.y = 6; 1 A var c = new A; b c Monday, 21 December 2009
  • 47. x: 5 var A = function () {}; y: 6 A.prototype.x = 5; var b = new A; A.prototype.y = 6; 1 A var c = new A; b.z = 7; b c z: 7 Monday, 21 December 2009
  • 48. x: 5 var A = function () {}; y: 6 A.prototype.x = 5; var b = new A; A.prototype.y = 6; 1 A var c = new A; b.z = 7; c.x = 4; b c z: 7 x: 4 Monday, 21 December 2009
  • 49. x: 5 w: 1 var A = function () {}; y: 6 u: 2 A.prototype.x = 5; var b = new A; A.prototype.y = 6; 1 A 2 var c = new A; b.z = 7; c.x = 4; A.prototype = { w: 1, u: 2 b c }; z: 7 x: 4 Monday, 21 December 2009
  • 50. x: 5 w: 1 var A = function () {}; y: 6 u: 2 A.prototype.x = 5; var b = new A; A.prototype.y = 6; 1 A 2 var c = new A; b.z = 7; c.x = 4; * A.prototype = { w: 1, u: 2 b c d }; var d = new A; z: 7 x: 4 — Monday, 21 December 2009
  • 51. x: 5 w: 1 var A = function () {}; y: 6 u: 2 A.prototype.x = 5; var b = new A; A.prototype.y = 6; 1 A 2 var c = new A; b.z = 7; c.x = 4; * A.prototype = { w: 1, u: 2 b c d }; var d = new A; z: 7 x: 4 — Monday, 21 December 2009
  • 52. Thank You Monday, 21 December 2009