-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJavascript.txt
More file actions
126 lines (100 loc) · 1.9 KB
/
Javascript.txt
File metadata and controls
126 lines (100 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
Developer Tools
//Comments
/*Multiple line comments*/
Variable Data Types
integer //all float 64 bits
strings //use "" or '' but don't mix them
boolean
Conditional Code
if(condition){}
< > == !=
Operators
Aritmetic
+ - * /
Assignment
=
Logical
&& (AND)
|| (OR)
Modulus
%
Increment / Decrement
++
--
Ternary
condition ? true : false
Loops
while(condition){}
do{}while(condition);
for(index;condition;increment){}
break
continue
Functions
function Name(Parameters){}
Arrays[]
methods()
The Math Object
Math.round();
Math.max();
String Properties
string.lenght
String Methods
phrase.toUpperCase();
prase.split(" ");
prase.indexOf("word"); //Returns -1 if not
prase.slice(start,lenght)
Date
Get Methods
getMonth()
getFullYear()
getYear()
getDate()
getDay()
getHours()
getTime()
Set Methods
setDay()
Comparing Dates
Objects
var = {property:value, property:value};
DOM
Node Types
Element
document.getElementByID("id");
document.getElementsByTagName("tag");
Create - Append Child
document.createElement("tag");
Attribute
getAttribute("attribute")
setAttribute("attribute")
Text
Events and Event Listeners
onload
onclick
onmouseover
onblur
onfocus
document.addEventListener('event',myFunction,false);
Timers
setTimeout(function,miliseconds);
setInterval(function,ms);
Styles
Element.style.property = value; //in camelCase
Element.className = class;
Coding Style
Use camelCase for variables, functions and methods
Case //Objects
Open curly braces on the same line
Always use blocks
Define functions before you call them
Always use var to define a variable
//Search javascript style guideline
Minification Tools
//
Quality Checker
JSLint
"use strict";
Regular Expressions
Javascript Prototypes
RESOURCES
https://developer.mozilla.org/en/JavaScript/Guide