SlideShare a Scribd company logo
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

PDF
Введение в программирование (1 часть)
DOCX
Holographie numérique hors axe
PDF
Введение в SQL
PPTX
A Step Towards Data Orientation
PPTX
Introduction à JavaScript
PPTX
How2heap
PDF
ZIO-Direct - Functional Scala 2022
PDF
Sequence and Traverse - Part 1
Введение в программирование (1 часть)
Holographie numérique hors axe
Введение в SQL
A Step Towards Data Orientation
Introduction à JavaScript
How2heap
ZIO-Direct - Functional Scala 2022
Sequence and Traverse - Part 1

What's hot (20)

ODP
Symfony Best Practices
PDF
The MySQL Query Optimizer Explained Through Optimizer Trace
PPTX
공간SQL을 이용한 공간자료분석 기초실습
PDF
Deep Dive on ClickHouse Sharding and Replication-2202-09-22.pdf
PDF
Programming Languages: comparison, history, future
PDF
Clickhouse at Cloudflare. By Marek Vavrusa
PDF
syzkaller: the next gen kernel fuzzer
ODP
Rust Primer
PDF
MySQL8.0 SYS スキーマ概要
PPTX
Boost your productivity with Scala tooling!
PDF
MySQL Casual Talks Vol.4 「MySQL-5.6で始める全文検索 〜InnoDB FTS編〜」
PDF
MacOS memory allocator (libmalloc) Exploitation
PDF
La programmation fonctionnelle en javascript / PF
PDF
Notions de base de JavaScript
PDF
Alphorm.com Formation React : Les fondamentaux
PDF
Building Thick Clients with Tower in Rust
PDF
Embedding Generic Monadic Transformer into Scala. [Tfp2022]
PPTX
Jumpstart! From SQL to NoSQL -- Changing Your Mindset
PDF
Cours php -partie 1.pdf
PDF
Jose Miguel Holguin & Marc Salinas - Taller de análisis de memoria RAM en sis...
Symfony Best Practices
The MySQL Query Optimizer Explained Through Optimizer Trace
공간SQL을 이용한 공간자료분석 기초실습
Deep Dive on ClickHouse Sharding and Replication-2202-09-22.pdf
Programming Languages: comparison, history, future
Clickhouse at Cloudflare. By Marek Vavrusa
syzkaller: the next gen kernel fuzzer
Rust Primer
MySQL8.0 SYS スキーマ概要
Boost your productivity with Scala tooling!
MySQL Casual Talks Vol.4 「MySQL-5.6で始める全文検索 〜InnoDB FTS編〜」
MacOS memory allocator (libmalloc) Exploitation
La programmation fonctionnelle en javascript / PF
Notions de base de JavaScript
Alphorm.com Formation React : Les fondamentaux
Building Thick Clients with Tower in Rust
Embedding Generic Monadic Transformer into Scala. [Tfp2022]
Jumpstart! From SQL to NoSQL -- Changing Your Mindset
Cours php -partie 1.pdf
Jose Miguel Holguin & Marc Salinas - Taller de análisis de memoria RAM en sis...
Ad

Similar to Prototype programming in JavaScript (20)

PDF
Patterns and antipatterns
PDF
Новое в JavaScript: ES.Next, ECMAScript 2020, ES11, ES10, ES9, ES8, ES7, ES6,...
PDF
Node.js in 2020 - part 3
PDF
How are Race Conditions in single threaded JavaScript possible?
PDF
Node.js in 2020 - part 2
PDF
Race-conditions-web-locks-and-shared-memory
PDF
Serverless Clouds (FaaS) and request context isolation in Node.js
PDF
Asynchronous programming and mutlithreading
PDF
Node.js in 2020
PDF
Node.js in 2020 - part 1
PDF
Web Locks API
PDF
Private cloud without vendor lock // Serverless
PDF
Node.js middleware: Never again!
PDF
How to keep control and safety in the clouds
PDF
JavaScript в браузере: Web API (часть 1)
PPTX
Oh Composable World!
PDF
I need to create a page looks like a picture. But it looks different.pdf
PDF
Javascript Array map method
PDF
PythonOOP
PDF
Go: It's Not Just For Google
Patterns and antipatterns
Новое в JavaScript: ES.Next, ECMAScript 2020, ES11, ES10, ES9, ES8, ES7, ES6,...
Node.js in 2020 - part 3
How are Race Conditions in single threaded JavaScript possible?
Node.js in 2020 - part 2
Race-conditions-web-locks-and-shared-memory
Serverless Clouds (FaaS) and request context isolation in Node.js
Asynchronous programming and mutlithreading
Node.js in 2020
Node.js in 2020 - part 1
Web Locks API
Private cloud without vendor lock // Serverless
Node.js middleware: Never again!
How to keep control and safety in the clouds
JavaScript в браузере: Web API (часть 1)
Oh Composable World!
I need to create a page looks like a picture. But it looks different.pdf
Javascript Array map method
PythonOOP
Go: It's Not Just For Google
Ad

More from Timur Shemsedinov (16)

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

Recently uploaded (20)

PDF
AI in Product Development-omnex systems
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
top salesforce developer skills in 2025.pdf
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
System and Network Administraation Chapter 3
PPTX
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
medical staffing services at VALiNTRY
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
How Creative Agencies Leverage Project Management Software.pdf
PPTX
Introduction to Artificial Intelligence
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
Digital Strategies for Manufacturing Companies
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
AI in Product Development-omnex systems
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
top salesforce developer skills in 2025.pdf
Upgrade and Innovation Strategies for SAP ERP Customers
Which alternative to Crystal Reports is best for small or large businesses.pdf
System and Network Administraation Chapter 3
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
Navsoft: AI-Powered Business Solutions & Custom Software Development
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
medical staffing services at VALiNTRY
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
How Creative Agencies Leverage Project Management Software.pdf
Introduction to Artificial Intelligence
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Design an Analysis of Algorithms II-SECS-1021-03
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
How to Choose the Right IT Partner for Your Business in Malaysia
Digital Strategies for Manufacturing Companies
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...

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__