際際滷

際際滷Share a Scribd company logo
JavaScript
Georgy Grigoryev, Auriga, Inc.
2
弌仂舒于 于亠弍亳仆舒仂于:
于仂亟仆亶: 亳仂亳 JS, 亠舒仍亳亰舒亳亳 亳 舒仆亟舒.
仗亠舒仂 亳 亳仗亳亰舒亳.
仆仂于仆亠 从仂仆从亳亳 磶从舒, 从舒从 仂仆亳 亳仗仂仍亰ム.
 亳 从仂仆亠从
JS+HTML: BOM, DOM, 仂弍亳 亳 于仂亶于舒, AJAX
JS 亠亶仄于仂从亳: jQuery, AngularJS, CoffeeScript, Node.js
3
Javascript  仂磦亳仍 于 1995 亞仂亟
JavaScript  仂亰亟舒仍亳 于 从仂仄仗舒仆亳亳 Netscape
Navigator
于仂 磶从舒  亠仆亟舒仆 亶从
4
亠仆亟舒仆 亶从
舒弍仂舒仍 于 Mozzilla
Foundation  仄仂仄亠仆舒
亠 仂仆仂于舒仆亳, 于 2014
仗仂舒弍仂舒仍 仆亠从仂仍从仂
亟仆亠亶 于 从舒亠于亠 CEO
5
LiveScript JavaScript ECMAScript
LiveScript 仗仂磦亳仍 于
Netscape Navigator
仂亰亢亠, LiveScript
仗亠亠亳仄亠仆仂于舒仍亳 于 JavaScript
 仗仂仍亠 于仗从舒 Jscript,
Netscape 亳仆亳亳亳仂于舒仍舒
舒仆亟舒亳亰舒亳 于 ECMA
6
JScript
Microsoft , 仗 亞仂亟, 于仗亳仍 于仂 于亠亳
JavaScript, 仆舒亰于舒于 亠 JScript.
亠仆亟舒仆 亶从: 束弌亳舒亶亠, 仂 JavaScript
(仗仂亢舒仍亶舒, 仂仍从仂 仆亠 Jscript) 仗舒 于舒 仂
VBscript損
7
msn.com
仂磦亳仍 舒仆亠 亠仄 JavaScript
8
仗仂仍亰仂于舒仆亳亠 JavaScript
Web
Windows
Embedded language
Server
Client
9
FirefoxOS, Windows Phone
10
Node.js, ActionScript
11
弌舒仆亟舒
 ECMAScript  舒从舒仍仆舒 于亠亳 5.
 仂仍亠亟仆 于亠亳 6
 仗仂仍亰ム 于亠亳亳 5 亳 3
 丐舒弍仍亳舒 亠舒仍亳亰舒亳亳 ECMAScript 6
http://kangax.github.io/compat-table/es6/
12
JavaScript vs JScript
仂亟亳亠仄舒 于于仂亟舒-于于仂亟舒
ActiveX
13
IDE
WebStorm
Visual Studio 2008/201x
Sublime text 2/3
14
WebStorm
15
Visual Studio
16
Sublime text 2/3
17
舒仗从 JS 于 弍舒亰亠亠
丼亠亠亰 仂从 舒亟亠舒
仗仂仍亰 从亳仗 仆舒 舒仆亳亠
舒仗亳于 从仂仆仂仍 仂仍舒亟从亳
18
舒仗从 js 亠亠亰 仂从 舒亟亠舒
javascript:alert(hello world!);
19
舒仗从 从亳仗舒 亠亠亰 亰舒从仍舒亟从 于 弍舒亰亠亠
 javascript:var el=document.getElementById("tRSSREADER@911621291");
el.parentNode.removeChild(el);
20
舒亳于舒仆亳亠 从亳仗舒 仆舒 舒仆亳
<script type="text/javascript">
function button_click()
{
alert("Great!");
}
</script>
<script type="text/javascript" src=/slideshow/course-js-day-1/62504542/"javascript_test.js"></script>
21
仂亟从仍ム亠仆亳亠 从亳仗舒 亳亰 CDN
<script src=/slideshow/course-js-day-1/62504542/"/ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
22
弌亠亟于舒 舒亰舒弍仂从亳/仂仍舒亟从亳
仂仄仂 从仂亟舒 舒仆亳
亠弍舒亞亞亠 从亳仗仂于
仂仆仂仍 仂仍舒亟从亳
弌亠亟于舒 仂仍亠亢亳于舒仆亳 亰舒仗仂仂于 (仆亠 于亠亰亟亠)
23
弌亠亟于舒 仂仍亠亢亳于舒仆亳 亰舒仗仂仂于 Chrome
24
弌亠亟于舒 仂仍亠亢亳于舒仆亳 亰舒仗仂仂于 IE11
25
仂仆仂仍 弍舒亰亠舒
舒从亳亠从亳 于仂 于亠 弍舒亰亠舒(仂仆仂 仆亠 于 IE6)
仗仂仍仆磳 仗仂亳亰于仂仍仆亶 从仂亟
仂仆亠从仂仄 仍亢亳 亠从舒 舒仆亳舒
仂仗仆 于亠 仂弍亠从 仂 舒仆亳 亳 舒仄舒
舒仆亳舒
弌舒仆亟舒仆舒 亞仂舒 从仍舒于亳舒 F12
26
仂仆仂仍 于 Chrome
27
仂仆仂仍 于 IE11
28
仂于亠从舒 从仂仆仂仍亳
 alert(console test);
 console.log(function foo)
29
Jscript 于 Windows
仂亠仆仆亶 亳仆亠仗亠舒仂 wscript.exe 亳
从仂仆仂仍仆亶 亳仆亠仗亠舒仂 cscript.exe
30
舒弍仂舒  舒亶仍舒仄亳 JScript
var fso = new ActiveXObject("Scripting.FileSystemObject");
var a = fso.CreateTextFile("c:testfile.txt", true);
a.WriteLine("This is a test.");
a.Close();
wscript "d:jscript_write_to_file.js"
JScript
舒仗从 js 亠亠亰 从仂仄舒仆亟仆 仂从
31
仗亠舒仂 于 JavaScript
 仂仄仄亠仆舒亳亳 亳 从舒于从亳
//仂亟仆仂仂仆亶 从仂仄仄亠仆舒亳亶
/*
仄仆仂亞仂仂从亶 从仂仄仄亠仆舒亳亶
*/
alert("comment") //仄仂亢仆仂 亟于仂亶仆亠 亳仗仂仍亰仂于舒
alert('comment') // 仄仂亢仆仂 仂亟亳仆舒仆亠
alert("It's comment") // 仄仂亢仆仂 仂弍舒 亳仗舒 舒亰
32
仗亠舒仂 于 JavaScript
亳于舒亳于舒仆亳亠 亰仆舒亠仆亳亶:
var a = "value";
b = "what?";
33
仗亠舒仂 于 JavaScript
丕仍仂于仆亶 仂仗亠舒仂:
var a = 1;
var b = 2;
if (a == b) {
console.log("equal");
} else {
console.log('not equal');
}
34
仗亠舒仂 于 JavaScript
丶亳从仍 while
var i = 0
while (i < 10) {
console.log(i)
i++;
}
35
仗亠舒仂 于 JavaScript
丶亳从仍 for
for(var i = 0; i <10;i++){
console.log(i);
}
36
仗亠舒仂 于 JavaScript
仗亠舒仂 switch
var a = 't';
switch(a){
case 't':
console.log("it's equal t");
break;
case 'y':
console.log("it's equal y");
break;
default:
console.log("empty");
break;
}
37
仗亠舒仂 于 JavaScript
亳仄亠亳亠从亳亠 仂仗亠舒仂
var a = 2;
var b = 3;
console.log(a+b);
console.log(a-b);
console.log(a*b);
console.log(a/b);
console.log(a%b); // 仂舒仂从 仂 亟亠仍亠仆亳
38
仗亠舒仂 于 JavaScript
仆从亠仄亠仆, 亟亠从亠仄亠仆. 仗亠舒仂 亟仂仗仆 从舒从 仗仂- 舒从 亳 仗亠-.
var b = 15;
for(var i = 1; i < 10 ; i++)
{
console.log(i);
console.log(--b);
}
39
仗亠舒仂 于 JavaScript
丐亠仆舒仆亶 仍仂于仆亶 仂仗亠舒仂:
console.log(1==2?"matrix":"not matrix");
40
仗亠舒仂 于 JavaScript
舒仗舒
var a,b,c;
for (a = 1, b = 3, c = a*b; a < 10; a++) {
console.log(a);
console.log(b);
console.log(c);
}
41
仗亠舒仂 于 JavaScript
丐仂从舒  亰舒仗仂亶
var a = 1;
a++; var t = a*2;
42
仗亠舒仂 仄亠仆ム亳亠 仄仍 仗亳 仗亠亠于仂亟亠 仂从亳
仂- 亳仆从亠仄亠仆
仂- 亟亠从亠仄亠仆
continue
break
return
throw
43
仗亠舒仂 仄亠仆ム亳亠 仄仍
亠 亰舒舒弍仂舒亠:
function GetPerson() {
return
{
"name":"John Doe",
"age": 30
}
}
44
弍仍舒 于亳亟亳仄仂亳
亠亞亟舒 亳仗仂仍亰亶亠 var!
function ShowTip(){
message = "debug info";
console.log(message);
}
message = "Hello user!";
console.log(message);
ShowTip();
console.log(message);
45
弍仍舒 于亳亟亳仄仂亳
弍仍舒 于亳亟亳仄仂亳 仂亰亟舒ム 仂仍从仂 仄亠仂亟
if(message!="")
{
var counter = 1;
}
console.log(counter);
46
4 亳仗舒 亟舒仆仆
Number
String
Boolean
Object
47
Number
8 弍舒亶, 仗仍舒于舒ム舒 仂从舒
弌仗亠亳舒仍仆亠 亰仆舒亠仆亳: NaN, Infinity
48
String
仄仄舒弍亠仍仆舒
仄亠亠 于仂亠仆仆亠 仄亠仂亟 舒弍仂 仂 仂从舒仄亳
var str = "".concat("Embeded ", "string ", "functions! ");
console.log(str.trim().substr(0, 18));
var str = "Embeded string functions!";
console.log(str.substr(-10));
substr, substring
49
亠仂弍舒亰仂于舒仆亳亠 亳仗仂于
亠仂弍舒亰仂于舒仆亳亠 于 仂从
document.title = 1 > 0;
var a = "2";
var b = 1;
var c = a + b;
console.log(c);
50
亠仂弍舒亰仂于舒仆亳亠 亳仗仂于
亠仂弍舒亰仂于舒仆亳亠 于 亳仍仂
var a = "123";
if (Number(a) == 123) {
console.log("is true");
}
var a = "123";
if (+a == 123) {
console.log("is true");
}
51
亠仂弍舒亰仂于舒仆亳亠 亳仗仂于
亠仂弍舒亰仂于舒仆亳亠 于 亳仍仂
console.log(Number(true)); // 1
console.log(Number(false)); // 0
console.log(Number(null)); // 0
console.log(Number(undefined))// NaN
52
亠仂弍舒亰仂于舒仆亳亠 亳仗仂于
亠仂弍舒亰仂于舒仆亳亠 于 弍仍亠于亶 亳仗
console.log(!!1); // true
console.log(!!0); // false
console.log(!!"foo"); // true
console.log(!!""); // false
console.log(!!NaN); // false
console.log(!!Infinity);// true
53
仂仆
舒亳 亠仆舒亟 - Wat?
https://www.destroyallsoftware.com/talks/wat
54
Contacts
Thank You and
We Look Forward to Working with You
Auriga, USA
92 Potter Rd, Ste 1
Wilton, NH 03086, USA
Phone: +1 (866) 645-1119
Fax: +1 (603) 386-6097
info@auriga.com
www.auriga.com
Auriga, Russia
125 Varshavskoe Shosse, Unit 16A
Moscow, 117587
Tel:+7 (495) 713-9900
Fax:+7 (495) 939-0300
info@auriga.com
www.auriga.com

More Related Content

course js day 1