SlideShare ist ein Scribd-Unternehmen logo
1 von 24
Coding For Kombol
10h January, 2015
Presenter: Riyadh Al Nur
Software Engineer
NewsCred
GitHub: riyadhalnur
Twitter: @riyadhalnur
Blog: blog.verticalaxisbd.com
Coding for Kombol | Riyadh Al Nur
Objects and Functions
Objects
Coding for Kombol | Riyadh Al Nur | Objects and Functions
● Standalone entity with a name and
property
● Object and property names are both
case-sensitive
● Everything’s an object except for null
and undefined
var myObj = {};
var myObj = new Object();
myObj.property1
myObj.Property1 // not the same as above
Object Properties
Coding for Kombol | Riyadh Al Nur | Objects and Functions
● Object properties can be of any type -
strings, functions, arrays
● Properties can be accessed by both dot
and bracket notation
var myObj.prop1 = ‘Hello’;
var myObj[‘prop1’] = ‘Hello’;
Instantiation
Coding for Kombol | Riyadh Al Nur | Objects and Functions
● Object initialisers
● Using constructor functions
● Object.create() method
var myObj = {};
function foo() {};
var bar = new foo();
var foo = {};
var bar = Object.create(foo);
Inheritance
Coding for Kombol | Riyadh Al Nur | Objects and Functions
● JavaScript is a prototype-based language
● All objects inherit from some other
object
● All properties available in prototype
object of constructor
var foo = {};
foo.prototype.prop1 = function() {
return ‘Hello World!’;
};
var bar = new foo();
bar.prop1();
// Hello World!
Methods vs. Prototypes
Coding for Kombol | Riyadh Al Nur | Objects and Functions
● Prototype based instances creates single
instance of properties
● Methods create instance for every single
invocation
● Properties attached via prototype are
shared
● The opposite for method based
properties
Functions
Coding for Kombol | Riyadh Al Nur | Objects and Functions
● First class members in JS
● To be exact, they are first-class objects
● Not the same as procedures
function add(a, b) {
return a + b;
}
// add(2,3) -> 5
Function Scope
Coding for Kombol | Riyadh Al Nur | Objects and Functions
● Functions can access variables inside the
scope it’s defined in only
● Functions inside another function can
access parent variables
var a = 2, b = 3;
function add() {
return a + b; // can access a & b
}
// add() -> 5
Recursion
Coding for Kombol | Riyadh Al Nur | Objects and Functions
● Functions can refer and call themselves
● 3 ways to do so:
● function name
● arguments.callee()
● in-scope variable that refers to
function
var foo = function bar() {};
// 1. bar()
// 2. arguments.callee()
// 3. foo()
Closures
Coding for Kombol | Riyadh Al Nur | Objects and Functions
● Inner function has access to outer
function’s variables
● Outer function does not have access to
inner function’s variables
var foo = (function bar() {
var string = ‘Hello’;
function strings() {
return string + ‘ World!’;
}
return strings();
})();
foo(); // Hello World!
Closures
Coding for Kombol | Riyadh Al Nur | Objects and Functions
● But, what happens when we do
something like this?
var myName = function (name) {
return {
setMyName: function(name) {
name = name;
}
};
};
Closures
Coding for Kombol | Riyadh Al Nur | Objects and Functions
● this refers to where a function is called,
not where it was defined!
NodeJS
The fact
Coding for Kombol | Riyadh Al Nur | Objects and Functions
● NodeJS is a JavaScript runtime
environment - not a language!
So why is it so special?
Coding for Kombol | Riyadh Al Nur | Objects and Functions
● Event driven
● Non-blocking I/O API
● Real-time apps someone?
Not so special but crucial points
● Runs on Google’s V8 JS engine
● Now front-end and back-end are in the
same language!
Under the hood
Coding for Kombol | Riyadh Al Nur | Objects and Functions
● Runs on a single-thread
o uses non-blocking I/O calls
o can handle thousands of concurrent
connections
● Unified API
o use the same services and models on
both server and client side
Under the hood
Coding for Kombol | Riyadh Al Nur | Objects and Functions
Image credit Toptal Engineering blog
Under the hood
Coding for Kombol | Riyadh Al Nur | Objects and Functions
● Event loop
o uses event loops instead of
processes and threads
o no explicit calls required - callbacks,
callbacks, callbacks!
The dark side
Coding for Kombol | Riyadh Al Nur | Objects and Functions
● Single thread = not good for heavy
computation
● App depends on a relational DB
Creating a simple HTTP server
Coding for Kombol | Riyadh Al Nur | Objects and Functions
var http = require(‘http’);
http.createServer(function (req, res) {
res.writeHead(200,
{‘Content-Type’: ‘text/plain’});
res.end(‘Hello World!n’);
}).listen(80);
ExpressJS
Coding for Kombol | Riyadh Al Nur | Objects and Functions
var express = require(‘express’);
// that easy
● A NodeJS web application framework
● Makes the previous example simpler but
more robust and powerful
Questions?

Weitere ähnliche Inhalte

Was ist angesagt?

AOT-compilation of JavaScript with V8
AOT-compilation of JavaScript with V8AOT-compilation of JavaScript with V8
AOT-compilation of JavaScript with V8Phil Eaton
 
Running Through Typescript
Running Through TypescriptRunning Through Typescript
Running Through TypescriptNikhil Wanpal
 
freeCodeCamp Tokyo Meetup #18
freeCodeCamp Tokyo Meetup #18freeCodeCamp Tokyo Meetup #18
freeCodeCamp Tokyo Meetup #18健太 田上
 
Swift language - A fast overview of some features
Swift language - A fast overview of some featuresSwift language - A fast overview of some features
Swift language - A fast overview of some featuresWeverton Timoteo
 
Kotlin & arrow: the functional way
Kotlin & arrow:  the functional wayKotlin & arrow:  the functional way
Kotlin & arrow: the functional waynluaces
 
Demistifying the 3D Web - part 2
Demistifying the 3D Web - part 2Demistifying the 3D Web - part 2
Demistifying the 3D Web - part 2Pietro Grandi
 
Introduction to Higher Order Functions in Scala
Introduction to Higher Order Functions in Scala	Introduction to Higher Order Functions in Scala
Introduction to Higher Order Functions in Scala Knoldus Inc.
 
java8-patterns
java8-patternsjava8-patterns
java8-patternsJustin Lin
 
Introduction to kotlin for Java Developer
Introduction to kotlin for Java DeveloperIntroduction to kotlin for Java Developer
Introduction to kotlin for Java Developertroubledkumi
 
Javascript omg!
Javascript omg!Javascript omg!
Javascript omg!bwullems
 
New c sharp4_features_part_v
New c sharp4_features_part_vNew c sharp4_features_part_v
New c sharp4_features_part_vNico Ludwig
 
Kotlin & Arrow the functional way
Kotlin & Arrow the functional wayKotlin & Arrow the functional way
Kotlin & Arrow the functional wayThoughtworks
 
Google Dart Pecha Kucha from OOP 2012
Google Dart Pecha Kucha from OOP 2012Google Dart Pecha Kucha from OOP 2012
Google Dart Pecha Kucha from OOP 2012Eberhard Wolff
 
CPP13 - Object Orientation
CPP13 - Object OrientationCPP13 - Object Orientation
CPP13 - Object OrientationMichael Heron
 

Was ist angesagt? (20)

AOT-compilation of JavaScript with V8
AOT-compilation of JavaScript with V8AOT-compilation of JavaScript with V8
AOT-compilation of JavaScript with V8
 
Running Through Typescript
Running Through TypescriptRunning Through Typescript
Running Through Typescript
 
freeCodeCamp Tokyo Meetup #18
freeCodeCamp Tokyo Meetup #18freeCodeCamp Tokyo Meetup #18
freeCodeCamp Tokyo Meetup #18
 
Swift language - A fast overview of some features
Swift language - A fast overview of some featuresSwift language - A fast overview of some features
Swift language - A fast overview of some features
 
15 Minutes Null
15 Minutes Null15 Minutes Null
15 Minutes Null
 
Kotlin & arrow: the functional way
Kotlin & arrow:  the functional wayKotlin & arrow:  the functional way
Kotlin & arrow: the functional way
 
Valgrind
ValgrindValgrind
Valgrind
 
Hanoi JUG: Java 8 & lambdas
Hanoi JUG: Java 8 & lambdasHanoi JUG: Java 8 & lambdas
Hanoi JUG: Java 8 & lambdas
 
C#
C#C#
C#
 
C#
C#C#
C#
 
C#
C#C#
C#
 
Demistifying the 3D Web - part 2
Demistifying the 3D Web - part 2Demistifying the 3D Web - part 2
Demistifying the 3D Web - part 2
 
Introduction to Higher Order Functions in Scala
Introduction to Higher Order Functions in Scala	Introduction to Higher Order Functions in Scala
Introduction to Higher Order Functions in Scala
 
java8-patterns
java8-patternsjava8-patterns
java8-patterns
 
Introduction to kotlin for Java Developer
Introduction to kotlin for Java DeveloperIntroduction to kotlin for Java Developer
Introduction to kotlin for Java Developer
 
Javascript omg!
Javascript omg!Javascript omg!
Javascript omg!
 
New c sharp4_features_part_v
New c sharp4_features_part_vNew c sharp4_features_part_v
New c sharp4_features_part_v
 
Kotlin & Arrow the functional way
Kotlin & Arrow the functional wayKotlin & Arrow the functional way
Kotlin & Arrow the functional way
 
Google Dart Pecha Kucha from OOP 2012
Google Dart Pecha Kucha from OOP 2012Google Dart Pecha Kucha from OOP 2012
Google Dart Pecha Kucha from OOP 2012
 
CPP13 - Object Orientation
CPP13 - Object OrientationCPP13 - Object Orientation
CPP13 - Object Orientation
 

Andere mochten auch

Introduction to Client-Side Javascript
Introduction to Client-Side JavascriptIntroduction to Client-Side Javascript
Introduction to Client-Side JavascriptJulie Iskander
 
01659-ANSF-translation
01659-ANSF-translation01659-ANSF-translation
01659-ANSF-translationNicola Marchi
 
Pharmaceutical R&D China Sourcing Pilot Final Report
Pharmaceutical R&D  China Sourcing Pilot  Final Report Pharmaceutical R&D  China Sourcing Pilot  Final Report
Pharmaceutical R&D China Sourcing Pilot Final Report Dragon Sourcing
 
Ransomware is Here: Fundamentals Everyone Needs to Know
Ransomware is Here: Fundamentals Everyone Needs to KnowRansomware is Here: Fundamentals Everyone Needs to Know
Ransomware is Here: Fundamentals Everyone Needs to KnowJeremiah Grossman
 
Tce pe - 2013 - prestação de contas compesa exercício 2008 - necessidade c...
Tce pe - 2013 - prestação de contas compesa exercício 2008 - necessidade c...Tce pe - 2013 - prestação de contas compesa exercício 2008 - necessidade c...
Tce pe - 2013 - prestação de contas compesa exercício 2008 - necessidade c...Noelia Brito
 
Journal of Industrial Safety Engineering vol 3 issue 3
Journal of Industrial Safety Engineering vol 3 issue 3Journal of Industrial Safety Engineering vol 3 issue 3
Journal of Industrial Safety Engineering vol 3 issue 3STM Journals
 
Packaging and chemicals case study
Packaging and chemicals case studyPackaging and chemicals case study
Packaging and chemicals case studyDragon Sourcing
 
World Peace Yoga School : Ayurveda
World Peace Yoga School : AyurvedaWorld Peace Yoga School : Ayurveda
World Peace Yoga School : AyurvedaYoga School
 
Research & Reviews A Journal of Immunology vol 6 issue 3
Research & Reviews A Journal of Immunology vol 6 issue 3Research & Reviews A Journal of Immunology vol 6 issue 3
Research & Reviews A Journal of Immunology vol 6 issue 3STM Journals
 

Andere mochten auch (13)

Introduction to Client-Side Javascript
Introduction to Client-Side JavascriptIntroduction to Client-Side Javascript
Introduction to Client-Side Javascript
 
Presentación1
Presentación1Presentación1
Presentación1
 
01659-ANSF-translation
01659-ANSF-translation01659-ANSF-translation
01659-ANSF-translation
 
Pharmaceutical R&D China Sourcing Pilot Final Report
Pharmaceutical R&D  China Sourcing Pilot  Final Report Pharmaceutical R&D  China Sourcing Pilot  Final Report
Pharmaceutical R&D China Sourcing Pilot Final Report
 
Ransomware is Here: Fundamentals Everyone Needs to Know
Ransomware is Here: Fundamentals Everyone Needs to KnowRansomware is Here: Fundamentals Everyone Needs to Know
Ransomware is Here: Fundamentals Everyone Needs to Know
 
Tce pe - 2013 - prestação de contas compesa exercício 2008 - necessidade c...
Tce pe - 2013 - prestação de contas compesa exercício 2008 - necessidade c...Tce pe - 2013 - prestação de contas compesa exercício 2008 - necessidade c...
Tce pe - 2013 - prestação de contas compesa exercício 2008 - necessidade c...
 
Journal of Industrial Safety Engineering vol 3 issue 3
Journal of Industrial Safety Engineering vol 3 issue 3Journal of Industrial Safety Engineering vol 3 issue 3
Journal of Industrial Safety Engineering vol 3 issue 3
 
Sp chap2
Sp chap2Sp chap2
Sp chap2
 
FossilShale Corporate Overview
FossilShale Corporate OverviewFossilShale Corporate Overview
FossilShale Corporate Overview
 
Packaging and chemicals case study
Packaging and chemicals case studyPackaging and chemicals case study
Packaging and chemicals case study
 
World Peace Yoga School : Ayurveda
World Peace Yoga School : AyurvedaWorld Peace Yoga School : Ayurveda
World Peace Yoga School : Ayurveda
 
Bachilleratodigital wix
Bachilleratodigital wixBachilleratodigital wix
Bachilleratodigital wix
 
Research & Reviews A Journal of Immunology vol 6 issue 3
Research & Reviews A Journal of Immunology vol 6 issue 3Research & Reviews A Journal of Immunology vol 6 issue 3
Research & Reviews A Journal of Immunology vol 6 issue 3
 

Ähnlich wie Code for kombol - Objects and Functions in JS and NodeJS

Ch-4 Middleware Architectures.pptx
Ch-4 Middleware Architectures.pptxCh-4 Middleware Architectures.pptx
Ch-4 Middleware Architectures.pptxdagilema
 
Lecture4 corba
Lecture4   corbaLecture4   corba
Lecture4 corbapoovi117
 
Dmytro Dziubenko "Developer's toolchain"
Dmytro Dziubenko "Developer's toolchain"Dmytro Dziubenko "Developer's toolchain"
Dmytro Dziubenko "Developer's toolchain"Fwdays
 
Writing mruby Debugger
Writing mruby DebuggerWriting mruby Debugger
Writing mruby Debuggeryamanekko
 
Jit builder status and directions 2018 03-28
Jit builder status and directions 2018 03-28Jit builder status and directions 2018 03-28
Jit builder status and directions 2018 03-28Mark Stoodley
 
Erp5 presentation plone_symosium_tokyo_2015
Erp5 presentation plone_symosium_tokyo_2015Erp5 presentation plone_symosium_tokyo_2015
Erp5 presentation plone_symosium_tokyo_2015taharayusei
 
Best Angular JS training in Hyderabad, India
Best Angular JS training in Hyderabad, IndiaBest Angular JS training in Hyderabad, India
Best Angular JS training in Hyderabad, IndiaN Benchmark IT Solutions
 
Kotlin in the age of digital transformation
Kotlin   in the age of digital transformationKotlin   in the age of digital transformation
Kotlin in the age of digital transformationRajmahendra Hegde
 
JavaScript: Patterns, Part 3
JavaScript: Patterns, Part  3JavaScript: Patterns, Part  3
JavaScript: Patterns, Part 3Chris Farrell
 
Building modular enterprise scale angular js applications
Building modular enterprise scale angular js applicationsBuilding modular enterprise scale angular js applications
Building modular enterprise scale angular js applicationsJonathan Fontanez
 
Functional Programming in JavaScript & ESNext
Functional Programming in JavaScript & ESNextFunctional Programming in JavaScript & ESNext
Functional Programming in JavaScript & ESNextUnfold UI
 
Testing with Express, Mocha & Chai
Testing with Express, Mocha & ChaiTesting with Express, Mocha & Chai
Testing with Express, Mocha & ChaiJoerg Henning
 
Enforcing API Design Rules for High Quality Code Generation
Enforcing API Design Rules for High Quality Code GenerationEnforcing API Design Rules for High Quality Code Generation
Enforcing API Design Rules for High Quality Code GenerationTim Burks
 
JavaScript objects and functions
JavaScript objects and functionsJavaScript objects and functions
JavaScript objects and functionsVictor Verhaagen
 
JavaScript Interview Questions Part - 1.pdf
JavaScript Interview Questions Part - 1.pdfJavaScript Interview Questions Part - 1.pdf
JavaScript Interview Questions Part - 1.pdfkatarichallenge
 
Intro to java 8
Intro to java 8Intro to java 8
Intro to java 8John Godoi
 

Ähnlich wie Code for kombol - Objects and Functions in JS and NodeJS (20)

Ch-4 Middleware Architectures.pptx
Ch-4 Middleware Architectures.pptxCh-4 Middleware Architectures.pptx
Ch-4 Middleware Architectures.pptx
 
Lecture4 corba
Lecture4   corbaLecture4   corba
Lecture4 corba
 
Dmytro Dziubenko "Developer's toolchain"
Dmytro Dziubenko "Developer's toolchain"Dmytro Dziubenko "Developer's toolchain"
Dmytro Dziubenko "Developer's toolchain"
 
Writing mruby Debugger
Writing mruby DebuggerWriting mruby Debugger
Writing mruby Debugger
 
Jit builder status and directions 2018 03-28
Jit builder status and directions 2018 03-28Jit builder status and directions 2018 03-28
Jit builder status and directions 2018 03-28
 
Erp5 presentation plone_symosium_tokyo_2015
Erp5 presentation plone_symosium_tokyo_2015Erp5 presentation plone_symosium_tokyo_2015
Erp5 presentation plone_symosium_tokyo_2015
 
Learn TypeScript from scratch
Learn TypeScript from scratchLearn TypeScript from scratch
Learn TypeScript from scratch
 
Best Angular JS training in Hyderabad, India
Best Angular JS training in Hyderabad, IndiaBest Angular JS training in Hyderabad, India
Best Angular JS training in Hyderabad, India
 
Kotlin in the age of digital transformation
Kotlin   in the age of digital transformationKotlin   in the age of digital transformation
Kotlin in the age of digital transformation
 
Web Assembly
Web AssemblyWeb Assembly
Web Assembly
 
JavaScript: Patterns, Part 3
JavaScript: Patterns, Part  3JavaScript: Patterns, Part  3
JavaScript: Patterns, Part 3
 
Building modular enterprise scale angular js applications
Building modular enterprise scale angular js applicationsBuilding modular enterprise scale angular js applications
Building modular enterprise scale angular js applications
 
From Perl To Elixir
From Perl To ElixirFrom Perl To Elixir
From Perl To Elixir
 
Functional Programming in JavaScript & ESNext
Functional Programming in JavaScript & ESNextFunctional Programming in JavaScript & ESNext
Functional Programming in JavaScript & ESNext
 
Testing with Express, Mocha & Chai
Testing with Express, Mocha & ChaiTesting with Express, Mocha & Chai
Testing with Express, Mocha & Chai
 
Enforcing API Design Rules for High Quality Code Generation
Enforcing API Design Rules for High Quality Code GenerationEnforcing API Design Rules for High Quality Code Generation
Enforcing API Design Rules for High Quality Code Generation
 
Advance JS and oop
Advance JS and oopAdvance JS and oop
Advance JS and oop
 
JavaScript objects and functions
JavaScript objects and functionsJavaScript objects and functions
JavaScript objects and functions
 
JavaScript Interview Questions Part - 1.pdf
JavaScript Interview Questions Part - 1.pdfJavaScript Interview Questions Part - 1.pdf
JavaScript Interview Questions Part - 1.pdf
 
Intro to java 8
Intro to java 8Intro to java 8
Intro to java 8
 

Kürzlich hochgeladen

英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxReal-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxRTS corp
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...Akihiro Suda
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Developmentvyaparkranti
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Natan Silnitsky
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZABSYZ Inc
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 

Kürzlich hochgeladen (20)

英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxReal-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Development
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
Advantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your BusinessAdvantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your Business
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZ
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 

Code for kombol - Objects and Functions in JS and NodeJS

  • 1. Coding For Kombol 10h January, 2015 Presenter: Riyadh Al Nur Software Engineer NewsCred
  • 2. GitHub: riyadhalnur Twitter: @riyadhalnur Blog: blog.verticalaxisbd.com Coding for Kombol | Riyadh Al Nur
  • 4. Objects Coding for Kombol | Riyadh Al Nur | Objects and Functions ● Standalone entity with a name and property ● Object and property names are both case-sensitive ● Everything’s an object except for null and undefined var myObj = {}; var myObj = new Object(); myObj.property1 myObj.Property1 // not the same as above
  • 5. Object Properties Coding for Kombol | Riyadh Al Nur | Objects and Functions ● Object properties can be of any type - strings, functions, arrays ● Properties can be accessed by both dot and bracket notation var myObj.prop1 = ‘Hello’; var myObj[‘prop1’] = ‘Hello’;
  • 6. Instantiation Coding for Kombol | Riyadh Al Nur | Objects and Functions ● Object initialisers ● Using constructor functions ● Object.create() method var myObj = {}; function foo() {}; var bar = new foo(); var foo = {}; var bar = Object.create(foo);
  • 7. Inheritance Coding for Kombol | Riyadh Al Nur | Objects and Functions ● JavaScript is a prototype-based language ● All objects inherit from some other object ● All properties available in prototype object of constructor var foo = {}; foo.prototype.prop1 = function() { return ‘Hello World!’; }; var bar = new foo(); bar.prop1(); // Hello World!
  • 8. Methods vs. Prototypes Coding for Kombol | Riyadh Al Nur | Objects and Functions ● Prototype based instances creates single instance of properties ● Methods create instance for every single invocation ● Properties attached via prototype are shared ● The opposite for method based properties
  • 9. Functions Coding for Kombol | Riyadh Al Nur | Objects and Functions ● First class members in JS ● To be exact, they are first-class objects ● Not the same as procedures function add(a, b) { return a + b; } // add(2,3) -> 5
  • 10. Function Scope Coding for Kombol | Riyadh Al Nur | Objects and Functions ● Functions can access variables inside the scope it’s defined in only ● Functions inside another function can access parent variables var a = 2, b = 3; function add() { return a + b; // can access a & b } // add() -> 5
  • 11. Recursion Coding for Kombol | Riyadh Al Nur | Objects and Functions ● Functions can refer and call themselves ● 3 ways to do so: ● function name ● arguments.callee() ● in-scope variable that refers to function var foo = function bar() {}; // 1. bar() // 2. arguments.callee() // 3. foo()
  • 12. Closures Coding for Kombol | Riyadh Al Nur | Objects and Functions ● Inner function has access to outer function’s variables ● Outer function does not have access to inner function’s variables var foo = (function bar() { var string = ‘Hello’; function strings() { return string + ‘ World!’; } return strings(); })(); foo(); // Hello World!
  • 13. Closures Coding for Kombol | Riyadh Al Nur | Objects and Functions ● But, what happens when we do something like this? var myName = function (name) { return { setMyName: function(name) { name = name; } }; };
  • 14. Closures Coding for Kombol | Riyadh Al Nur | Objects and Functions ● this refers to where a function is called, not where it was defined!
  • 16. The fact Coding for Kombol | Riyadh Al Nur | Objects and Functions ● NodeJS is a JavaScript runtime environment - not a language!
  • 17. So why is it so special? Coding for Kombol | Riyadh Al Nur | Objects and Functions ● Event driven ● Non-blocking I/O API ● Real-time apps someone? Not so special but crucial points ● Runs on Google’s V8 JS engine ● Now front-end and back-end are in the same language!
  • 18. Under the hood Coding for Kombol | Riyadh Al Nur | Objects and Functions ● Runs on a single-thread o uses non-blocking I/O calls o can handle thousands of concurrent connections ● Unified API o use the same services and models on both server and client side
  • 19. Under the hood Coding for Kombol | Riyadh Al Nur | Objects and Functions Image credit Toptal Engineering blog
  • 20. Under the hood Coding for Kombol | Riyadh Al Nur | Objects and Functions ● Event loop o uses event loops instead of processes and threads o no explicit calls required - callbacks, callbacks, callbacks!
  • 21. The dark side Coding for Kombol | Riyadh Al Nur | Objects and Functions ● Single thread = not good for heavy computation ● App depends on a relational DB
  • 22. Creating a simple HTTP server Coding for Kombol | Riyadh Al Nur | Objects and Functions var http = require(‘http’); http.createServer(function (req, res) { res.writeHead(200, {‘Content-Type’: ‘text/plain’}); res.end(‘Hello World!n’); }).listen(80);
  • 23. ExpressJS Coding for Kombol | Riyadh Al Nur | Objects and Functions var express = require(‘express’); // that easy ● A NodeJS web application framework ● Makes the previous example simpler but more robust and powerful