Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
new JavaScript
Search
Stepan Stolyarov
October 19, 2012
Programming
540
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
new JavaScript
Введение в язык JavaScript для чайников
Stepan Stolyarov
October 19, 2012
Other Decks in Programming
See All in Programming
Verilogで学ぶCPU自作入門
uyuki234
8
4.1k
コーディング自動化の次へ。人の介入をゼロにするファクトリーとサポートAIによる実践
timakin
4
3.5k
FactoryBotをやめればRSpecは速くなるのか?
yuta_onishi_97
0
270
sbt 2.0: takeoff
eed3si9n
0
160
Kotlinの15年とServer-Side Kotlin
n_takehata
1
150
contenteditable と日本語入力に向き合う
colorful12
0
200
パスワード再設定メールのURLについて知っておこう
uyuki234
0
160
Long Living Tokens, Die, Die, Die! (or: The One Ring is Banned in Modern)
sylph01
0
300
SREの越境 / SRE Collaboration
y0hgi
2
310
ソニーのクラウド共通基盤の変遷とAI時代の開発スタイルに合わせた進化 / The Journey of Sony’s Common Cloud Platform and Its Evolution for AI-Native Development
kenjiyoneyama
0
270
AWS CDKのカスタムリソースでContinuum(旧Security Agent)を実装した話 | Implementing Continuum (formerly Security Agent) via AWS CDK Custom Resource
akihisaikeda
2
150
APNsからLive Activityを開始する話
yumnumm
0
170
Featured
See All Featured
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
2
6.3k
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.4k
Google's AI Overviews - The New Search
badams
0
1.6k
Bash Introduction
62gerente
615
220k
Producing Creativity
orderedlist
PRO
348
41k
Why Our Code Smells
bkeepers
PRO
340
58k
Context Engineering - Making Every Token Count
addyosmani
9
1.2k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
540
Code Reviewing Like a Champion
maltzj
529
40k
Faster Mobile Websites
deanohume
310
32k
Paper Plane (Part 1)
katiecoart
PRO
2
12k
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.6k
Transcript
new JavaScript;
Самый популярный
№1 на GitHub
время, затраченное на поиск официальной версии логотипа загадочный субъективный параметр
Самый доступный
В каждом браузере
...и не только
Самый простой
{}
f()
В JavaScript нет • паттерн-матчинга • лист компрехеншнов • континьюэйшнов
• корутин • монад • языковой поддержки модулей • огромной стандартной библиотеки • классов с названиями типа SQLIntegrityConstraintViolationException • и вообще классов
f() {}
f() <: {}
Function — это объект Object — это функция
{}
two = 2; yes = true; obj = {}; str
= "hello"; arr = []; nop = function () {}; rex = /dog/; now = new Date;
None
two = 2; yes = true; obj = {}; str
= "hello"; arr = []; nop = function () {}; rex = /dog/; now = new Date;
new
> typeof Date "function" > Date() "Wed Oct 17 2012
18:13:52 GMT+0700 (NOVT)" > new Date() Wed Oct 17 2012 18:13:54 GMT+0700 (NOVT)
> typeof Date() "string" > typeof (new Date()) "object"
object.constructor
two.constructor == Number; yes.constructor == Boolean; obj.constructor == Object; str.constructor
== String; arr.constructor == Array; nop.constructor == Function; rex.constructor == RegExp; now.constructor == Date;
function Person(first, last) { this.firstName = first; this.lastName = last;
} var bob = new Person('Bob'); bob.firstName; // 'Bob'
> bob.constructor === Person true > bob instanceof Person true
> empty = {} ▸ Object > empty.constructor function Object()
{ ... } > empty.toString() "[object Object]"
> empty = {} ▾ Object ▾ __proto__: Object ...
▸ constructor: function... ▸ isPrototypeOf: function... ▸ toString: function... ▸ valueOf: function... ...
null
> zen = Object.create(null) ▾ Object No Properties > zen
instanceof Object false > typeof zen "object"
person = Object.create(null); person.fullName = function () { return this.firstName
+ ' ' + this.lastName; }; man = Object.create(person); man.sex = 'male';
bob = Object.create(man); bob.firstName = 'bob'; bob.lastName = 'smith'; bob.sex;
// 'male' bob.fullName(); // 'bob smith'
> bob ▾ Object firstName: "bob" lastName: "smith" ▾ __proto__:
Object sex: "male" ▾ __proto__: Object ▸ fullName: function...
null sex "male" fullName function () { ... } firstName
"bob" lastName "smith" person man bob
function Person(first, last) { this.firstName = first; this.lastName = last;
} var bob = new Person('Bob'); bob.firstName; // 'Bob'
function Person(first, last) { this.firstName = first; this.lastName = last;
this.fullName = function () { return this.firstName + ' ' + this.lastName; } }
firstName "bob" lastName "smith" fullName function () ... bob firstName
"alice" lastName "jones" fullName function () ... alice
Constructor.prototype
function Person(first, last) { this.firstName = first; this.lastName = last;
} Person.prototype.fullName = function () { return this.firstName + ' ' + this.lastName; }
firstName "bob" lastName "smith" bob firstName "alice" lastName "jones" alice
fullName function () ... Person.prototype
f()
Объекты первого класса
function foo() { return 'FOO'; }
var bar = foo; bar(); // 'FOO'
function baz(f) { return f(); } baz(foo); // 'FOO'
function quux() { return foo; } quux()(); // 'FOO'
var code = 'return "FOO"' var foo = new Function(code);
foo(); // 'FOO'
Область видимости переменных
var
function fred(x) { var a = 10; return a *
x; } var a = 3; fred(5); // 50 console.log(a); // 3
function fred(x) { /*no var*/ a = 10; return a
* x; } var a = 3; fred(5); // 50 console.log(a); // 10
this
Person.prototype.fullName = function () { return this.firstName + ' '
+ this.lastName; } bob = new Person('bob'); bob.fullName(); // 'bob undefined'
xavier = { firstName: 'xavier', lastName: 'sanchez' }; xavier.fullName(); //
error!
xavier.fullName = Person.prototype.fullName; xavier.fullName(); // 'xavier sanchez'
Person.prototype .fullName .call(xavier); // 'xavier sanchez'
that
function Logger(s) { s.on('data', function (d) { this.log(d); }); }
Logger.prototype.log = function (data) { console.log(new Date, data); }
function Logger(s) { s.on('data', function (d) { this.log(d); }); }
function Logger(s) { var that = this; s.on('data', function (d)
{ that.log(d); }); }
function Logger(s) { s.on('data', Logger.prototype .log.bind(this)); }
@stevebest https://github.com/stevebest jifasnif