SlideShare a Scribd company logo
1 of 31
Download to read offline
JavaScript for PHP
                           developers
                                   The Good Parts

                           Karsten Dambekalns <karsten@typo3.org>




Freitag, 15. Mai 2009
What this is about
                        the JavaScript language


                        not DOM
                        not browsers
                        not JS frameworks
                        not website building

Freitag, 15. Mai 2009
Am I qualified?

                        Probably not, when it comes to JS
                        Absolutely when it comes to PHP




Freitag, 15. Mai 2009
My JS background
                        First JS usage in the days of NN4
                        Used DynAPI, modified it
                        Saw alert() fix timing issues in browsers
                        Was happy when I did not have to use
                        JavaScript anymore
                        Thought I would never touch it again


Freitag, 15. Mai 2009
In JavaScript, there is
             a beautiful, elegant,
              highly expressive
                 language...

Freitag, 15. Mai 2009
...that is buried under
               a steaming pile of
             good intentions and
                    blunders.
                          Douglas Crockford


Freitag, 15. Mai 2009
Grammar


Freitag, 15. Mai 2009
Names
                        Names can be chosen freely
                        Some words are reserved, most of them not
                        used in JavaScript, though
                        Some word should have been reserved:
                          NaN, Infinity, undefined



Freitag, 15. Mai 2009
Numbers

                        Only one type, 64 bit floating point internally
                        Numbers have methods


                        (Most things in JavaScript are objects)



Freitag, 15. Mai 2009
Strings
                        16 bit Unicode, as such somewhat limited
                        Strings have methods and properties
                        toUpperCase(), length
                        Concatenation is done with +, as is addition

                        (Beware of errors as a result of this!)


Freitag, 15. Mai 2009
var
                        Most confusing for me was var – it seemed to
                        make no difference most of the time
                        Inside a function var defines a function’s
                        private variables
                        Otherwise variables will be globally accessible!



Freitag, 15. Mai 2009
Type issues
                        typeof returns a string with a type
                        For arrays and null it returns ‘object’
                        typeof NaN === ‘number’ // true!
                        undefined and NaN are global variables – you
                        can change their values



Freitag, 15. Mai 2009
Functions


Freitag, 15. Mai 2009
Basics

                        Functions are objects, they can be
                          stored in variables, arrays, objects
                          passed as arguments and returned
                        Functions can have methods (they are objects!)



Freitag, 15. Mai 2009
Defining functions
                        JavaScript has a function statement and a
                        function expression:
                         function foo() {}
                        means about the same as
                         var foo = function foo() {}
                        Remember: functions are values



Freitag, 15. Mai 2009
Closure
                        Inner functions can access parameters and
                        variables of the context in which they are
                        created
                        This can be used
                          to protect variables against manipulation
                          to keep values over function calls


Freitag, 15. Mai 2009
var myObject = function () {
                var value = 0;
                return {
                   increment: function (inc) {
                      value += typeof inc === ‘number ? inc : 1;
                   }
                   getValue: function () {
                      return value;
                   }
           }();


Freitag, 15. Mai 2009
Objects


Freitag, 15. Mai 2009
Basics
                        Numbers, strings, booleans, null, undefined are
                        simple types
                        Everything else is an object: arrays, functions,
                        regular expressions
                        Objects have properties with name and value
                        Objects are class free


Freitag, 15. Mai 2009
Object literals
                        Very cool way of creating objects, confusing if
                        seen for the first time (no new?!)
                        var flight = {
                          airline: ‘FLOW Flights’,
                          number: 3,
                          captain: { ... }
                        }


Freitag, 15. Mai 2009
The new statement
                        new creates an object that inherits from the
                        operand, then calls the operand with the
                        created object bound to this
                        If the operand customizes the object but you
                        forgot new, you change global variables!
                        If you use new, make constructor method
                        names UpperCamelCase


Freitag, 15. Mai 2009
Inheritance
                        Objects inherit from objects, no classes
                        Prototypal inheritence allows to augment
                        existing objects during runtime:
                         Foo.prototype.bar = function () { ... }
                        Even built-in objects can be enhanced
                        Local properties hide inherited ones


Freitag, 15. Mai 2009
Arrays


Freitag, 15. Mai 2009
Basics
                        Arrays can be created with array literals:
                         var data = [‘one’, ‘two’, ‘three’];
                        The length property of an array
                          is the largest integer property name +1
                          can be set and thus cut off arrays at the end



Freitag, 15. Mai 2009
Array or Object?
                        Simple rule for what to use:
                        When property names are small sequential
                        integers, use an array. Otherwise an object.
                        Hard to find out what you have:
                        You need to define a useful is_array method
                        yourself.



Freitag, 15. Mai 2009
Awful & bad parts


Freitag, 15. Mai 2009
Semicolon inerstion
                        JavaScript tries to fix programs by inserting
                        semicolons – do not rely on that!
                        What does this return?
                        return
                        {
                          status: true
                        };


Freitag, 15. Mai 2009
parseInt

                        parseInt(’16’) == parseInt(’16 tons’) == 16
                        parseInt(’08’) returns 0 because it assumes
                        octal numbers
                        Always provide the radix parameter to parseInt




Freitag, 15. Mai 2009
Bitwise operators

                        Avoid them if you think you gain speed
                        All numbers are floating point, so bitwise
                        operators convert to integer and back




Freitag, 15. Mai 2009
Read this!
               JavaScript: The Good Parts
                   Douglas Crockford
                        O’Reilly




Freitag, 15. Mai 2009
Thanks!


Freitag, 15. Mai 2009

More Related Content

Viewers also liked

pathology practical original slide NO2
pathology practical original slide NO2pathology practical original slide NO2
pathology practical original slide NO2kushrokz
 
NEUROPATHOLOGY LECTURE 2009*
NEUROPATHOLOGY LECTURE 2009*NEUROPATHOLOGY LECTURE 2009*
NEUROPATHOLOGY LECTURE 2009*Michael Thomas
 
pathology practical original slide NO1
pathology practical original slide NO1pathology practical original slide NO1
pathology practical original slide NO1kushrokz
 
13 facial neuropathology
13 facial neuropathology13 facial neuropathology
13 facial neuropathologyEphrem Tamiru
 
B Cell Development
B Cell DevelopmentB Cell Development
B Cell Developmentraj kumar
 
8. Acute Lymphoblastic Leukemia
8. Acute Lymphoblastic Leukemia8. Acute Lymphoblastic Leukemia
8. Acute Lymphoblastic LeukemiaWhiteraven68
 
Acute lymphoid leukemia (case presentation)
Acute lymphoid leukemia (case presentation)Acute lymphoid leukemia (case presentation)
Acute lymphoid leukemia (case presentation)Dhritiman Chakrabarti
 
Social Media for Chicago Community Trust presentation
Social Media for Chicago Community Trust presentationSocial Media for Chicago Community Trust presentation
Social Media for Chicago Community Trust presentationHack the Hood
 
Project execution for paranoids
Project execution for paranoidsProject execution for paranoids
Project execution for paranoidsHack the Hood
 
2.2 My Works About Use Case Analysis, Flowchart
2.2 My Works About Use Case Analysis, Flowchart2.2 My Works About Use Case Analysis, Flowchart
2.2 My Works About Use Case Analysis, FlowchartRuby Kuo
 
03 - Le Rôle des Universités / The Role of Universities
03 - Le Rôle des Universités / The Role of Universities03 - Le Rôle des Universités / The Role of Universities
03 - Le Rôle des Universités / The Role of UniversitiesMohamed Larbi BEN YOUNES
 
1001 Ona Career Day Preso
1001 Ona Career Day Preso1001 Ona Career Day Preso
1001 Ona Career Day PresoHack the Hood
 
Lvw Model Kids
Lvw Model   KidsLvw Model   Kids
Lvw Model KidsJosh Allen
 
Visual studio tools 4 SharePoint SharePoint Saturday Arabia
Visual studio tools 4 SharePoint SharePoint Saturday ArabiaVisual studio tools 4 SharePoint SharePoint Saturday Arabia
Visual studio tools 4 SharePoint SharePoint Saturday ArabiaMarwan Tarek
 
A Kaleidoscopic Analysis of the Sing Up Project [clip]
A Kaleidoscopic Analysis of the Sing Up Project [clip]A Kaleidoscopic Analysis of the Sing Up Project [clip]
A Kaleidoscopic Analysis of the Sing Up Project [clip]Antia G. Ben
 
Digital Marketing e Mobile Marketing
Digital Marketing e Mobile MarketingDigital Marketing e Mobile Marketing
Digital Marketing e Mobile MarketingLeonardo Milan
 

Viewers also liked (20)

pathology practical original slide NO2
pathology practical original slide NO2pathology practical original slide NO2
pathology practical original slide NO2
 
NEUROPATHOLOGY LECTURE 2009*
NEUROPATHOLOGY LECTURE 2009*NEUROPATHOLOGY LECTURE 2009*
NEUROPATHOLOGY LECTURE 2009*
 
pathology practical original slide NO1
pathology practical original slide NO1pathology practical original slide NO1
pathology practical original slide NO1
 
13 facial neuropathology
13 facial neuropathology13 facial neuropathology
13 facial neuropathology
 
B cell lymphoma
B cell lymphomaB cell lymphoma
B cell lymphoma
 
B Cell Development
B Cell DevelopmentB Cell Development
B Cell Development
 
8. Acute Lymphoblastic Leukemia
8. Acute Lymphoblastic Leukemia8. Acute Lymphoblastic Leukemia
8. Acute Lymphoblastic Leukemia
 
Acute lymphoid leukemia (case presentation)
Acute lymphoid leukemia (case presentation)Acute lymphoid leukemia (case presentation)
Acute lymphoid leukemia (case presentation)
 
Social Media for Chicago Community Trust presentation
Social Media for Chicago Community Trust presentationSocial Media for Chicago Community Trust presentation
Social Media for Chicago Community Trust presentation
 
Project execution for paranoids
Project execution for paranoidsProject execution for paranoids
Project execution for paranoids
 
2.2 My Works About Use Case Analysis, Flowchart
2.2 My Works About Use Case Analysis, Flowchart2.2 My Works About Use Case Analysis, Flowchart
2.2 My Works About Use Case Analysis, Flowchart
 
Formacion en entorno presencial y virtual
Formacion en entorno presencial y virtualFormacion en entorno presencial y virtual
Formacion en entorno presencial y virtual
 
State of Plone Caching
State of Plone CachingState of Plone Caching
State of Plone Caching
 
Task 1
Task 1Task 1
Task 1
 
03 - Le Rôle des Universités / The Role of Universities
03 - Le Rôle des Universités / The Role of Universities03 - Le Rôle des Universités / The Role of Universities
03 - Le Rôle des Universités / The Role of Universities
 
1001 Ona Career Day Preso
1001 Ona Career Day Preso1001 Ona Career Day Preso
1001 Ona Career Day Preso
 
Lvw Model Kids
Lvw Model   KidsLvw Model   Kids
Lvw Model Kids
 
Visual studio tools 4 SharePoint SharePoint Saturday Arabia
Visual studio tools 4 SharePoint SharePoint Saturday ArabiaVisual studio tools 4 SharePoint SharePoint Saturday Arabia
Visual studio tools 4 SharePoint SharePoint Saturday Arabia
 
A Kaleidoscopic Analysis of the Sing Up Project [clip]
A Kaleidoscopic Analysis of the Sing Up Project [clip]A Kaleidoscopic Analysis of the Sing Up Project [clip]
A Kaleidoscopic Analysis of the Sing Up Project [clip]
 
Digital Marketing e Mobile Marketing
Digital Marketing e Mobile MarketingDigital Marketing e Mobile Marketing
Digital Marketing e Mobile Marketing
 

Similar to JavaScript for PHP Devs: The Good Parts (40

JSUG - ActionScript 3 vs Java by Christoph Pickl
JSUG - ActionScript 3 vs Java by Christoph PicklJSUG - ActionScript 3 vs Java by Christoph Pickl
JSUG - ActionScript 3 vs Java by Christoph PicklChristoph Pickl
 
JSUG - AS3 vs Java by Christoph Pickl
JSUG - AS3 vs Java by Christoph PicklJSUG - AS3 vs Java by Christoph Pickl
JSUG - AS3 vs Java by Christoph PicklChristoph Pickl
 
Functional Java Script - Webtechcon 2009
Functional Java Script - Webtechcon 2009Functional Java Script - Webtechcon 2009
Functional Java Script - Webtechcon 2009wolframkriesing
 
MacRuby - When objective-c and Ruby meet
MacRuby - When objective-c and Ruby meetMacRuby - When objective-c and Ruby meet
MacRuby - When objective-c and Ruby meetMatt Aimonetti
 
Building A Framework On Rack
Building A Framework On RackBuilding A Framework On Rack
Building A Framework On RackMatt Todd
 
Chad Udell - Developers are from Mars, Designers are from Venus
Chad Udell - Developers are from Mars, Designers are from VenusChad Udell - Developers are from Mars, Designers are from Venus
Chad Udell - Developers are from Mars, Designers are from Venus360|Conferences
 
Treetop - I'd rather have one problem
Treetop - I'd rather have one problemTreetop - I'd rather have one problem
Treetop - I'd rather have one problemRoland Swingler
 
Your java script library
Your java script libraryYour java script library
Your java script libraryjasfog
 
Objective-C A Beginner's Dive (with notes)
Objective-C A Beginner's Dive (with notes)Objective-C A Beginner's Dive (with notes)
Objective-C A Beginner's Dive (with notes)Altece
 

Similar to JavaScript for PHP Devs: The Good Parts (40 (12)

JSUG - ActionScript 3 vs Java by Christoph Pickl
JSUG - ActionScript 3 vs Java by Christoph PicklJSUG - ActionScript 3 vs Java by Christoph Pickl
JSUG - ActionScript 3 vs Java by Christoph Pickl
 
JSUG - AS3 vs Java by Christoph Pickl
JSUG - AS3 vs Java by Christoph PicklJSUG - AS3 vs Java by Christoph Pickl
JSUG - AS3 vs Java by Christoph Pickl
 
Clean Code
Clean CodeClean Code
Clean Code
 
Functional Java Script - Webtechcon 2009
Functional Java Script - Webtechcon 2009Functional Java Script - Webtechcon 2009
Functional Java Script - Webtechcon 2009
 
MacRuby - When objective-c and Ruby meet
MacRuby - When objective-c and Ruby meetMacRuby - When objective-c and Ruby meet
MacRuby - When objective-c and Ruby meet
 
Groovy
GroovyGroovy
Groovy
 
Building A Framework On Rack
Building A Framework On RackBuilding A Framework On Rack
Building A Framework On Rack
 
Chad Udell - Developers are from Mars, Designers are from Venus
Chad Udell - Developers are from Mars, Designers are from VenusChad Udell - Developers are from Mars, Designers are from Venus
Chad Udell - Developers are from Mars, Designers are from Venus
 
Treetop - I'd rather have one problem
Treetop - I'd rather have one problemTreetop - I'd rather have one problem
Treetop - I'd rather have one problem
 
Your java script library
Your java script libraryYour java script library
Your java script library
 
Objective-C A Beginner's Dive (with notes)
Objective-C A Beginner's Dive (with notes)Objective-C A Beginner's Dive (with notes)
Objective-C A Beginner's Dive (with notes)
 
Lecture 03
Lecture 03Lecture 03
Lecture 03
 

More from Karsten Dambekalns

The Perfect Neos Project Setup
The Perfect Neos Project SetupThe Perfect Neos Project Setup
The Perfect Neos Project SetupKarsten Dambekalns
 
Sawubona! Content Dimensions with Neos
Sawubona! Content Dimensions with NeosSawubona! Content Dimensions with Neos
Sawubona! Content Dimensions with NeosKarsten Dambekalns
 
Deploying TYPO3 Neos websites using Surf
Deploying TYPO3 Neos websites using SurfDeploying TYPO3 Neos websites using Surf
Deploying TYPO3 Neos websites using SurfKarsten Dambekalns
 
Profiling TYPO3 Flow Applications
Profiling TYPO3 Flow ApplicationsProfiling TYPO3 Flow Applications
Profiling TYPO3 Flow ApplicationsKarsten Dambekalns
 
Using Document Databases with TYPO3 Flow
Using Document Databases with TYPO3 FlowUsing Document Databases with TYPO3 Flow
Using Document Databases with TYPO3 FlowKarsten Dambekalns
 
How Git and Gerrit make you more productive
How Git and Gerrit make you more productiveHow Git and Gerrit make you more productive
How Git and Gerrit make you more productiveKarsten Dambekalns
 
The agile future of a ponderous project
The agile future of a ponderous projectThe agile future of a ponderous project
The agile future of a ponderous projectKarsten Dambekalns
 
How Domain-Driven Design helps you to migrate into the future
How Domain-Driven Design helps you to migrate into the futureHow Domain-Driven Design helps you to migrate into the future
How Domain-Driven Design helps you to migrate into the futureKarsten Dambekalns
 
Content Repository, Versioning and Workspaces in TYPO3 Phoenix
Content Repository, Versioning and Workspaces in TYPO3 PhoenixContent Repository, Versioning and Workspaces in TYPO3 Phoenix
Content Repository, Versioning and Workspaces in TYPO3 PhoenixKarsten Dambekalns
 
Transparent Object Persistence (within FLOW3)
Transparent Object Persistence (within FLOW3)Transparent Object Persistence (within FLOW3)
Transparent Object Persistence (within FLOW3)Karsten Dambekalns
 
Transparent Object Persistence with FLOW3
Transparent Object Persistence with FLOW3Transparent Object Persistence with FLOW3
Transparent Object Persistence with FLOW3Karsten Dambekalns
 
Implementing a JSR-283 Content Repository in PHP
Implementing a JSR-283 Content Repository in PHPImplementing a JSR-283 Content Repository in PHP
Implementing a JSR-283 Content Repository in PHPKarsten Dambekalns
 
Knowledge Management in der TYPO3 Community
Knowledge Management in der TYPO3 CommunityKnowledge Management in der TYPO3 Community
Knowledge Management in der TYPO3 CommunityKarsten Dambekalns
 
Implementing a JSR-283 Content Repository in PHP
Implementing a JSR-283 Content Repository in PHPImplementing a JSR-283 Content Repository in PHP
Implementing a JSR-283 Content Repository in PHPKarsten Dambekalns
 
A Content Repository for TYPO3 5.0
A Content Repository for TYPO3 5.0A Content Repository for TYPO3 5.0
A Content Repository for TYPO3 5.0Karsten Dambekalns
 
Introduction to Source Code Management
Introduction to Source Code ManagementIntroduction to Source Code Management
Introduction to Source Code ManagementKarsten Dambekalns
 

More from Karsten Dambekalns (20)

The Perfect Neos Project Setup
The Perfect Neos Project SetupThe Perfect Neos Project Setup
The Perfect Neos Project Setup
 
Sawubona! Content Dimensions with Neos
Sawubona! Content Dimensions with NeosSawubona! Content Dimensions with Neos
Sawubona! Content Dimensions with Neos
 
Deploying TYPO3 Neos websites using Surf
Deploying TYPO3 Neos websites using SurfDeploying TYPO3 Neos websites using Surf
Deploying TYPO3 Neos websites using Surf
 
Profiling TYPO3 Flow Applications
Profiling TYPO3 Flow ApplicationsProfiling TYPO3 Flow Applications
Profiling TYPO3 Flow Applications
 
Using Document Databases with TYPO3 Flow
Using Document Databases with TYPO3 FlowUsing Document Databases with TYPO3 Flow
Using Document Databases with TYPO3 Flow
 
i18n and L10n in TYPO3 Flow
i18n and L10n in TYPO3 Flowi18n and L10n in TYPO3 Flow
i18n and L10n in TYPO3 Flow
 
FLOW3-Workshop F3X12
FLOW3-Workshop F3X12FLOW3-Workshop F3X12
FLOW3-Workshop F3X12
 
Doctrine in FLOW3
Doctrine in FLOW3Doctrine in FLOW3
Doctrine in FLOW3
 
How Git and Gerrit make you more productive
How Git and Gerrit make you more productiveHow Git and Gerrit make you more productive
How Git and Gerrit make you more productive
 
The agile future of a ponderous project
The agile future of a ponderous projectThe agile future of a ponderous project
The agile future of a ponderous project
 
How Domain-Driven Design helps you to migrate into the future
How Domain-Driven Design helps you to migrate into the futureHow Domain-Driven Design helps you to migrate into the future
How Domain-Driven Design helps you to migrate into the future
 
Content Repository, Versioning and Workspaces in TYPO3 Phoenix
Content Repository, Versioning and Workspaces in TYPO3 PhoenixContent Repository, Versioning and Workspaces in TYPO3 Phoenix
Content Repository, Versioning and Workspaces in TYPO3 Phoenix
 
Transparent Object Persistence (within FLOW3)
Transparent Object Persistence (within FLOW3)Transparent Object Persistence (within FLOW3)
Transparent Object Persistence (within FLOW3)
 
Transparent Object Persistence with FLOW3
Transparent Object Persistence with FLOW3Transparent Object Persistence with FLOW3
Transparent Object Persistence with FLOW3
 
Implementing a JSR-283 Content Repository in PHP
Implementing a JSR-283 Content Repository in PHPImplementing a JSR-283 Content Repository in PHP
Implementing a JSR-283 Content Repository in PHP
 
Knowledge Management in der TYPO3 Community
Knowledge Management in der TYPO3 CommunityKnowledge Management in der TYPO3 Community
Knowledge Management in der TYPO3 Community
 
Unicode & PHP6
Unicode & PHP6Unicode & PHP6
Unicode & PHP6
 
Implementing a JSR-283 Content Repository in PHP
Implementing a JSR-283 Content Repository in PHPImplementing a JSR-283 Content Repository in PHP
Implementing a JSR-283 Content Repository in PHP
 
A Content Repository for TYPO3 5.0
A Content Repository for TYPO3 5.0A Content Repository for TYPO3 5.0
A Content Repository for TYPO3 5.0
 
Introduction to Source Code Management
Introduction to Source Code ManagementIntroduction to Source Code Management
Introduction to Source Code Management
 

Recently uploaded

Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 

Recently uploaded (20)

Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 

JavaScript for PHP Devs: The Good Parts (40

  • 1. JavaScript for PHP developers The Good Parts Karsten Dambekalns <karsten@typo3.org> Freitag, 15. Mai 2009
  • 2. What this is about the JavaScript language not DOM not browsers not JS frameworks not website building Freitag, 15. Mai 2009
  • 3. Am I qualified? Probably not, when it comes to JS Absolutely when it comes to PHP Freitag, 15. Mai 2009
  • 4. My JS background First JS usage in the days of NN4 Used DynAPI, modified it Saw alert() fix timing issues in browsers Was happy when I did not have to use JavaScript anymore Thought I would never touch it again Freitag, 15. Mai 2009
  • 5. In JavaScript, there is a beautiful, elegant, highly expressive language... Freitag, 15. Mai 2009
  • 6. ...that is buried under a steaming pile of good intentions and blunders. Douglas Crockford Freitag, 15. Mai 2009
  • 8. Names Names can be chosen freely Some words are reserved, most of them not used in JavaScript, though Some word should have been reserved: NaN, Infinity, undefined Freitag, 15. Mai 2009
  • 9. Numbers Only one type, 64 bit floating point internally Numbers have methods (Most things in JavaScript are objects) Freitag, 15. Mai 2009
  • 10. Strings 16 bit Unicode, as such somewhat limited Strings have methods and properties toUpperCase(), length Concatenation is done with +, as is addition (Beware of errors as a result of this!) Freitag, 15. Mai 2009
  • 11. var Most confusing for me was var – it seemed to make no difference most of the time Inside a function var defines a function’s private variables Otherwise variables will be globally accessible! Freitag, 15. Mai 2009
  • 12. Type issues typeof returns a string with a type For arrays and null it returns ‘object’ typeof NaN === ‘number’ // true! undefined and NaN are global variables – you can change their values Freitag, 15. Mai 2009
  • 14. Basics Functions are objects, they can be stored in variables, arrays, objects passed as arguments and returned Functions can have methods (they are objects!) Freitag, 15. Mai 2009
  • 15. Defining functions JavaScript has a function statement and a function expression: function foo() {} means about the same as var foo = function foo() {} Remember: functions are values Freitag, 15. Mai 2009
  • 16. Closure Inner functions can access parameters and variables of the context in which they are created This can be used to protect variables against manipulation to keep values over function calls Freitag, 15. Mai 2009
  • 17. var myObject = function () { var value = 0; return { increment: function (inc) { value += typeof inc === ‘number ? inc : 1; } getValue: function () { return value; } }(); Freitag, 15. Mai 2009
  • 19. Basics Numbers, strings, booleans, null, undefined are simple types Everything else is an object: arrays, functions, regular expressions Objects have properties with name and value Objects are class free Freitag, 15. Mai 2009
  • 20. Object literals Very cool way of creating objects, confusing if seen for the first time (no new?!) var flight = { airline: ‘FLOW Flights’, number: 3, captain: { ... } } Freitag, 15. Mai 2009
  • 21. The new statement new creates an object that inherits from the operand, then calls the operand with the created object bound to this If the operand customizes the object but you forgot new, you change global variables! If you use new, make constructor method names UpperCamelCase Freitag, 15. Mai 2009
  • 22. Inheritance Objects inherit from objects, no classes Prototypal inheritence allows to augment existing objects during runtime: Foo.prototype.bar = function () { ... } Even built-in objects can be enhanced Local properties hide inherited ones Freitag, 15. Mai 2009
  • 24. Basics Arrays can be created with array literals: var data = [‘one’, ‘two’, ‘three’]; The length property of an array is the largest integer property name +1 can be set and thus cut off arrays at the end Freitag, 15. Mai 2009
  • 25. Array or Object? Simple rule for what to use: When property names are small sequential integers, use an array. Otherwise an object. Hard to find out what you have: You need to define a useful is_array method yourself. Freitag, 15. Mai 2009
  • 26. Awful & bad parts Freitag, 15. Mai 2009
  • 27. Semicolon inerstion JavaScript tries to fix programs by inserting semicolons – do not rely on that! What does this return? return { status: true }; Freitag, 15. Mai 2009
  • 28. parseInt parseInt(’16’) == parseInt(’16 tons’) == 16 parseInt(’08’) returns 0 because it assumes octal numbers Always provide the radix parameter to parseInt Freitag, 15. Mai 2009
  • 29. Bitwise operators Avoid them if you think you gain speed All numbers are floating point, so bitwise operators convert to integer and back Freitag, 15. Mai 2009
  • 30. Read this! JavaScript: The Good Parts Douglas Crockford O’Reilly Freitag, 15. Mai 2009