SlideShare a Scribd company logo
2
Most read
const fs = require('fs'); const compose = (...funcs) => x => funcs.
reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab
table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma
=> (row.map((cell, i) => { const width = cellWidth[i]; return i ? c
toString().padStart(width) : cell.padEnd(width); }).join(''))).join
}; const proportion = (max, val) => Math.round(val * 100 / max); co
calcProportion = table => { table.sort((row1, row2) => row2[DENSITY
row1[DENSITY_COL]); const maxDensity = table[0][DENSITY_COL]; table
forEach(row => { row.push(proportion(maxDensity, row[DENSITY_COL]))
return table; }; const getDataset = file => { const lines = fs.read
FileSync(file, 'utf8').toString().split('n'); lines.shift(); lines
return lines.map(line => line.split(',')); }; const main = compose
(getDataset, calcProportion, renderTable); const fs = require('fs'
compose = (...funcs) => x => funcs.reduce((x, fn) => fn(x), x); con
DENSITY_COL = 3; const renderTable = table => { const cellWidth = [
8, 8, 18, 6]; return table.map(row => (row.map((cell, i) => { const
= cellWidth[i]; return i ? cell.toString().padStart(width) : cell.p
(width); }).join(''))).join('n'); }; const proportion = (max, val)
Прототипное
программирование
Тимур Шемсединов
github.com/HowProgrammingWorks
Chief Software Architect at Metarhia
Lecturer at Kiev Polytechnic Institute
github.com/tshemsedinov
const fs = require('fs'); const compose = (...funcs) => x => funcs.
reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab
table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma
=> (row.map((cell, i) => { const width = cellWidth[i]; return i ? c
1. point.__proto__ -> pointMethods
x: Number
y: Number
__proto__
point
move(x, y)
toString()
__proto__
pointMethods
point.__proto__
toString()
valueOf()
...
Object.prototype
pointMethods.__proto__
Object.prototype.__proto__
null
const fs = require('fs'); const compose = (...funcs) => x => funcs.
reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab
table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma
=> (row.map((cell, i) => { const width = cellWidth[i]; return i ? c
2. function Point(x, y) { ... }
x: Number
y: Number
__proto__
point
move(x, y)
toString()
constructor
__proto__
Point.prototype
__proto__
toString()
valueOf()
...
Object.prototype
null
__proto__ __proto__
from(obj)
prototype
__proto__
Point
constructor
prototype
apply, bind, call,
constructor
...
Function.prototype
__proto__
__proto__
const fs = require('fs'); const compose = (...funcs) => x => funcs.
reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab
table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma
=> (row.map((cell, i) => { const width = cellWidth[i]; return i ? c
3. class Point { ... }
x: Number
y: Number
__proto__
point
move(x, y)
toString()
constructor
__proto__
Point.prototype
__proto__
Object.prototype
null
__proto__ __proto__
from(obj)
prototype
__proto__
Point
constructor
prototype
Function.prototype
__proto__
__proto__
Object
Function
const fs = require('fs'); const compose = (...funcs) => x => funcs.
reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab
table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma
=> (row.map((cell, i) => { const width = cellWidth[i]; return i ? c
4. (#1, #2) square -> Square -> Rect
x: Number
y: Number
width: Number
height: Number
__proto__
square
move(x, y)
constructor
__proto__
Square.prototype
__proto__
Objectnull
__proto__
prototype
__proto__
Square
constructor
prototype
toString()
constructor
__proto__
Rect.prototype
prototype
__proto__
Rect
constructor
prototype
__proto__
Square.prototype
const fs = require('fs'); const compose = (...funcs) => x => funcs.
reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab
table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma
=> (row.map((cell, i) => { const width = cellWidth[i]; return i ? c
4. (#3, #4, #5) square -> Square -> Rect
x: Number
y: Number
width: Number
height: Number
__proto__
square
move(x, y)
constructor
__proto__
Square.prototype
__proto__
Objectnull
__proto__
prototype
__proto__
Square
constructor
prototype
toString()
constructor
__proto__
Rect.prototype
prototype
__proto__
Rect
constructor
prototype
__proto__
const fs = require('fs'); const compose = (...funcs) => x => funcs.
reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab
table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma
=> (row.map((cell, i) => { const width = cellWidth[i]; return i ? c
5. class Square extends Rect
x: Number
y: Number
width: Number
height: Number
__proto__
square
move(x, y)
constructor
__proto__
Square.prototype
__proto__
Object
__proto__
prototype
__proto__
class Square
constructor
prototype
toString()
constructor
__proto__
Rect.prototype
prototype
__proto__
class Rect
constructor
prototype
__proto__
__proto__
Function.prototype
__proto__

More Related Content

What's hot (20)

PDF
Nat, List and Option Monoids - from scratch - Combining and Folding - an example
Philip Schwarz
 
PPTX
Tipos de JOIN en SQL.pptx
MiguelLlerena5
 
PDF
Exploring the replication and sharding in MongoDB
Igor Donchovski
 
PDF
4.1 Operasi Dasar Singly Linked List 1 (primitive list)
Kelinci Coklat
 
PDF
A Prelude of Purity: Scaling Back ZIO
Jorge Vásquez
 
PDF
Java 8 Stream API. A different way to process collections.
David Gómez García
 
PDF
Algebraic Data Types for Data Oriented Programming - From Haskell and Scala t...
Philip Schwarz
 
PPTX
8. Multi List (Struktur Data)
Kelinci Coklat
 
PDF
Web Programming (Question Paper) [April – 2017 | 75:25 Pattern]
Mumbai B.Sc.IT Study
 
PDF
Why The Free Monad isn't Free
Kelley Robinson
 
PDF
Haskell study 2
Nam Hyeonuk
 
PPTX
Purely Functional Data Structures in Scala
Vladimir Kostyukov
 
PPTX
Array searching sorting_pert_11,12,13,14,15
doudomblogspot
 
PDF
Ad hoc Polymorphism using Type Classes and Cats
Philip Schwarz
 
PPT
OPERASI SISTEM BILANGAN.ppt
AsyerMilala
 
PDF
Laboratorio de XML en DB2
JOSE AHIAS LOPEZ PORTILLO
 
PDF
The New JavaScript: ES6
Rob Eisenberg
 
PPTX
Pertemuan 2 ~ Flowchart
Achmad Solichin
 
PDF
外部環境への依存をテストする
Shunsuke Maeda
 
PDF
Programming Languages: comparison, history, future
Timur Shemsedinov
 
Nat, List and Option Monoids - from scratch - Combining and Folding - an example
Philip Schwarz
 
Tipos de JOIN en SQL.pptx
MiguelLlerena5
 
Exploring the replication and sharding in MongoDB
Igor Donchovski
 
4.1 Operasi Dasar Singly Linked List 1 (primitive list)
Kelinci Coklat
 
A Prelude of Purity: Scaling Back ZIO
Jorge Vásquez
 
Java 8 Stream API. A different way to process collections.
David Gómez García
 
Algebraic Data Types for Data Oriented Programming - From Haskell and Scala t...
Philip Schwarz
 
8. Multi List (Struktur Data)
Kelinci Coklat
 
Web Programming (Question Paper) [April – 2017 | 75:25 Pattern]
Mumbai B.Sc.IT Study
 
Why The Free Monad isn't Free
Kelley Robinson
 
Haskell study 2
Nam Hyeonuk
 
Purely Functional Data Structures in Scala
Vladimir Kostyukov
 
Array searching sorting_pert_11,12,13,14,15
doudomblogspot
 
Ad hoc Polymorphism using Type Classes and Cats
Philip Schwarz
 
OPERASI SISTEM BILANGAN.ppt
AsyerMilala
 
Laboratorio de XML en DB2
JOSE AHIAS LOPEZ PORTILLO
 
The New JavaScript: ES6
Rob Eisenberg
 
Pertemuan 2 ~ Flowchart
Achmad Solichin
 
外部環境への依存をテストする
Shunsuke Maeda
 
Programming Languages: comparison, history, future
Timur Shemsedinov
 

Similar to Prototype programming in JavaScript (14)

PDF
Node.js in 2020 - part 2
Timur Shemsedinov
 
PDF
Patterns and antipatterns
Timur Shemsedinov
 
PDF
Node.js in 2020 - part 3
Timur Shemsedinov
 
PDF
Новое в JavaScript: ES.Next, ECMAScript 2020, ES11, ES10, ES9, ES8, ES7, ES6,...
Timur Shemsedinov
 
PDF
Node.js in 2020 - part 1
Timur Shemsedinov
 
PDF
How are Race Conditions in single threaded JavaScript possible?
Timur Shemsedinov
 
PDF
Asynchronous programming and mutlithreading
Timur Shemsedinov
 
PDF
Race-conditions-web-locks-and-shared-memory
Timur Shemsedinov
 
PDF
Node.js in 2020
Timur Shemsedinov
 
PDF
JavaScript в браузере: Web API (часть 1)
Timur Shemsedinov
 
PDF
Web Locks API
Timur Shemsedinov
 
PDF
Private cloud without vendor lock // Serverless
Timur Shemsedinov
 
PDF
Serverless Clouds (FaaS) and request context isolation in Node.js
Timur Shemsedinov
 
PDF
How to keep control and safety in the clouds
Timur Shemsedinov
 
Node.js in 2020 - part 2
Timur Shemsedinov
 
Patterns and antipatterns
Timur Shemsedinov
 
Node.js in 2020 - part 3
Timur Shemsedinov
 
Новое в JavaScript: ES.Next, ECMAScript 2020, ES11, ES10, ES9, ES8, ES7, ES6,...
Timur Shemsedinov
 
Node.js in 2020 - part 1
Timur Shemsedinov
 
How are Race Conditions in single threaded JavaScript possible?
Timur Shemsedinov
 
Asynchronous programming and mutlithreading
Timur Shemsedinov
 
Race-conditions-web-locks-and-shared-memory
Timur Shemsedinov
 
Node.js in 2020
Timur Shemsedinov
 
JavaScript в браузере: Web API (часть 1)
Timur Shemsedinov
 
Web Locks API
Timur Shemsedinov
 
Private cloud without vendor lock // Serverless
Timur Shemsedinov
 
Serverless Clouds (FaaS) and request context isolation in Node.js
Timur Shemsedinov
 
How to keep control and safety in the clouds
Timur Shemsedinov
 
Ad

More from Timur Shemsedinov (16)

PDF
How to use Chat GPT in JavaScript optimizations for Node.js
Timur Shemsedinov
 
PDF
IT Revolution in 2023-2024: AI, GPT, business transformation, future professi...
Timur Shemsedinov
 
PDF
Multithreading in Node.js and JavaScript
Timur Shemsedinov
 
PDF
Node.js threads for I/O-bound tasks
Timur Shemsedinov
 
PDF
Node.js Меньше сложности, больше надежности Holy.js 2021
Timur Shemsedinov
 
PDF
Rethinking low-code
Timur Shemsedinov
 
PDF
Hat full of developers
Timur Shemsedinov
 
PDF
FwDays 2021: Metarhia Technology Stack for Node.js
Timur Shemsedinov
 
PDF
Node.js for enterprise - JS Conference
Timur Shemsedinov
 
PDF
Node.js for enterprise 2021 - JavaScript Fwdays 3
Timur Shemsedinov
 
PDF
Node.js in 2021
Timur Shemsedinov
 
PDF
Information system structure and architecture
Timur Shemsedinov
 
PDF
Базы данных в 2020
Timur Shemsedinov
 
PDF
Почему хорошее ИТ-образование невостребовано рыночком
Timur Shemsedinov
 
PDF
Node.js security
Timur Shemsedinov
 
PDF
JS Fest 2019 Node.js Antipatterns
Timur Shemsedinov
 
How to use Chat GPT in JavaScript optimizations for Node.js
Timur Shemsedinov
 
IT Revolution in 2023-2024: AI, GPT, business transformation, future professi...
Timur Shemsedinov
 
Multithreading in Node.js and JavaScript
Timur Shemsedinov
 
Node.js threads for I/O-bound tasks
Timur Shemsedinov
 
Node.js Меньше сложности, больше надежности Holy.js 2021
Timur Shemsedinov
 
Rethinking low-code
Timur Shemsedinov
 
Hat full of developers
Timur Shemsedinov
 
FwDays 2021: Metarhia Technology Stack for Node.js
Timur Shemsedinov
 
Node.js for enterprise - JS Conference
Timur Shemsedinov
 
Node.js for enterprise 2021 - JavaScript Fwdays 3
Timur Shemsedinov
 
Node.js in 2021
Timur Shemsedinov
 
Information system structure and architecture
Timur Shemsedinov
 
Базы данных в 2020
Timur Shemsedinov
 
Почему хорошее ИТ-образование невостребовано рыночком
Timur Shemsedinov
 
Node.js security
Timur Shemsedinov
 
JS Fest 2019 Node.js Antipatterns
Timur Shemsedinov
 
Ad

Recently uploaded (20)

PDF
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
PDF
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
PPTX
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
PDF
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
PPTX
Comprehensive Risk Assessment Module for Smarter Risk Management
EHA Soft Solutions
 
PDF
AOMEI Partition Assistant Crack 10.8.2 + WinPE Free Downlaod New Version 2025
bashirkhan333g
 
PDF
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
PPTX
Customise Your Correlation Table in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PDF
MiniTool Power Data Recovery 8.8 With Crack New Latest 2025
bashirkhan333g
 
PDF
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
PDF
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
PPTX
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
PPTX
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
PDF
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
PPTX
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PDF
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
PDF
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
PDF
NEW-Viral>Wondershare Filmora 14.5.18.12900 Crack Free
sherryg1122g
 
PPTX
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
Finding Your License Details in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
Comprehensive Risk Assessment Module for Smarter Risk Management
EHA Soft Solutions
 
AOMEI Partition Assistant Crack 10.8.2 + WinPE Free Downlaod New Version 2025
bashirkhan333g
 
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
Customise Your Correlation Table in IBM SPSS Statistics.pptx
Version 1 Analytics
 
MiniTool Power Data Recovery 8.8 With Crack New Latest 2025
bashirkhan333g
 
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
NEW-Viral>Wondershare Filmora 14.5.18.12900 Crack Free
sherryg1122g
 
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Finding Your License Details in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 

Prototype programming in JavaScript

  • 1. const fs = require('fs'); const compose = (...funcs) => x => funcs. reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma => (row.map((cell, i) => { const width = cellWidth[i]; return i ? c toString().padStart(width) : cell.padEnd(width); }).join(''))).join }; const proportion = (max, val) => Math.round(val * 100 / max); co calcProportion = table => { table.sort((row1, row2) => row2[DENSITY row1[DENSITY_COL]); const maxDensity = table[0][DENSITY_COL]; table forEach(row => { row.push(proportion(maxDensity, row[DENSITY_COL])) return table; }; const getDataset = file => { const lines = fs.read FileSync(file, 'utf8').toString().split('n'); lines.shift(); lines return lines.map(line => line.split(',')); }; const main = compose (getDataset, calcProportion, renderTable); const fs = require('fs' compose = (...funcs) => x => funcs.reduce((x, fn) => fn(x), x); con DENSITY_COL = 3; const renderTable = table => { const cellWidth = [ 8, 8, 18, 6]; return table.map(row => (row.map((cell, i) => { const = cellWidth[i]; return i ? cell.toString().padStart(width) : cell.p (width); }).join(''))).join('n'); }; const proportion = (max, val) Прототипное программирование Тимур Шемсединов github.com/HowProgrammingWorks Chief Software Architect at Metarhia Lecturer at Kiev Polytechnic Institute github.com/tshemsedinov
  • 2. const fs = require('fs'); const compose = (...funcs) => x => funcs. reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma => (row.map((cell, i) => { const width = cellWidth[i]; return i ? c 1. point.__proto__ -> pointMethods x: Number y: Number __proto__ point move(x, y) toString() __proto__ pointMethods point.__proto__ toString() valueOf() ... Object.prototype pointMethods.__proto__ Object.prototype.__proto__ null
  • 3. const fs = require('fs'); const compose = (...funcs) => x => funcs. reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma => (row.map((cell, i) => { const width = cellWidth[i]; return i ? c 2. function Point(x, y) { ... } x: Number y: Number __proto__ point move(x, y) toString() constructor __proto__ Point.prototype __proto__ toString() valueOf() ... Object.prototype null __proto__ __proto__ from(obj) prototype __proto__ Point constructor prototype apply, bind, call, constructor ... Function.prototype __proto__ __proto__
  • 4. const fs = require('fs'); const compose = (...funcs) => x => funcs. reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma => (row.map((cell, i) => { const width = cellWidth[i]; return i ? c 3. class Point { ... } x: Number y: Number __proto__ point move(x, y) toString() constructor __proto__ Point.prototype __proto__ Object.prototype null __proto__ __proto__ from(obj) prototype __proto__ Point constructor prototype Function.prototype __proto__ __proto__ Object Function
  • 5. const fs = require('fs'); const compose = (...funcs) => x => funcs. reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma => (row.map((cell, i) => { const width = cellWidth[i]; return i ? c 4. (#1, #2) square -> Square -> Rect x: Number y: Number width: Number height: Number __proto__ square move(x, y) constructor __proto__ Square.prototype __proto__ Objectnull __proto__ prototype __proto__ Square constructor prototype toString() constructor __proto__ Rect.prototype prototype __proto__ Rect constructor prototype __proto__ Square.prototype
  • 6. const fs = require('fs'); const compose = (...funcs) => x => funcs. reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma => (row.map((cell, i) => { const width = cellWidth[i]; return i ? c 4. (#3, #4, #5) square -> Square -> Rect x: Number y: Number width: Number height: Number __proto__ square move(x, y) constructor __proto__ Square.prototype __proto__ Objectnull __proto__ prototype __proto__ Square constructor prototype toString() constructor __proto__ Rect.prototype prototype __proto__ Rect constructor prototype __proto__
  • 7. const fs = require('fs'); const compose = (...funcs) => x => funcs. reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma => (row.map((cell, i) => { const width = cellWidth[i]; return i ? c 5. class Square extends Rect x: Number y: Number width: Number height: Number __proto__ square move(x, y) constructor __proto__ Square.prototype __proto__ Object __proto__ prototype __proto__ class Square constructor prototype toString() constructor __proto__ Rect.prototype prototype __proto__ class Rect constructor prototype __proto__ __proto__ Function.prototype __proto__