|
1 | 1 | # JavaScript Cheatsheet |
2 | 2 |
|
3 | 3 |
|
4 | | -**JavaScript (or JS)** |
| 4 | +###JavaScript (or JS) |
| 5 | + |
5 | 6 | It is a popular programming language commonly used to create interactive effects within web browsers |
6 | 7 |
|
7 | 8 |
|
8 | | -**variable** |
| 9 | +###variable |
| 10 | + |
9 | 11 | A place to store values, can store any kind of information(data types): numbers, words, collections of data |
10 | 12 |
|
11 | 13 |
|
12 | | -**undefined variable** |
| 14 | +###undefined variable |
| 15 | + |
13 | 16 | A variable that has no value |
14 | 17 |
|
15 | | -**to declare variable** |
| 18 | +###to declare variable |
| 19 | + |
16 | 20 | To create a variable - done by using ‘ var variable-name = value ’ |
17 | 21 |
|
18 | 22 |
|
19 | | -**to initialize variable** |
| 23 | +###to initialize variable |
| 24 | + |
20 | 25 | Set (give) some value to variable. |
21 | 26 |
|
22 | | -**string** |
| 27 | +###string |
| 28 | + |
23 | 29 | A set of characters, word, phrase. To initialize variable with a string you need to put this string into quotes. |
24 | 30 |
|
25 | | -**boolean** |
| 31 | +###boolean |
| 32 | + |
26 | 33 | Boolean variable represent a logical values True or False |
27 | 34 |
|
28 | 35 |
|
29 | | -**array** |
| 36 | +###array |
| 37 | + |
30 | 38 | An ordered list of values, can store different type of data inside |
31 | 39 |
|
32 | 40 |
|
33 | | -**operator** |
| 41 | +###operator |
| 42 | + |
34 | 43 | Mathematical operators, such as: +, -, *, /, >, <, = etc |
35 | 44 |
|
36 | 45 |
|
37 | | -**comments** |
| 46 | +###comments |
| 47 | + |
38 | 48 | Comments are some notes that you can leave for yourself or another person, the note that computer will not read. You can write a comment on a new line or on the same line after code as so: //I’m your comment |
39 | 49 | Single line comment starts with // |
40 | 50 | Multi line comment are placed between /* .. */ |
41 | 51 |
|
42 | 52 |
|
43 | | -**function** |
| 53 | +###function |
| 54 | + |
44 | 55 | A separable, reusable piece of code. It takes some input do some manipulation on it and return us output |
45 | 56 |
|
46 | 57 |
|
47 | | -**to declare function** |
| 58 | +###to declare function |
| 59 | + |
48 | 60 | To create a function |
49 | 61 |
|
50 | | -**argument** |
| 62 | +###argument |
| 63 | + |
51 | 64 | A value input that functions can accept |
52 | 65 |
|
53 | 66 |
|
54 | | -**if/else statement** |
| 67 | +###if/else statement |
| 68 | + |
55 | 69 | ‘If’ used to decide which lines of code to execute, ‘else’ - to give alternative set of instructions. Example: if(x > 5) {console.log”X bigger than 5”}; else {console.log”X smaller than 5”}; |
56 | 70 |
|
57 | 71 |
|
58 | | -**while loop** |
| 72 | +###while loop |
| 73 | + |
59 | 74 | It repeats code over and over again until some condition is met |
60 | 75 |
|
61 | 76 |
|
62 | | -**for loop** |
| 77 | +###for loop |
| 78 | + |
63 | 79 | This loop is similar to ‘while loop’, just with set amount of repetition. You declare counter in the statement as so: for(var i = 0; i < 5; i++){do something 5 times}; |
64 | 80 |
|
65 | 81 |
|
66 | | -**infinite loop** |
| 82 | +###infinite loop |
| 83 | + |
67 | 84 | A loop that does not stop and it’s a loop that you need to avoid. Each loop should have some condition so it can stop. |
68 | 85 |
|
69 | 86 |
|
70 | | -**object** |
| 87 | +###object |
| 88 | + |
71 | 89 | A collection of properties |
72 | 90 |
|
73 | 91 |
|
74 | | -**event** |
| 92 | +###event |
| 93 | + |
75 | 94 | A type of object that is created when user interacts with web page. For example, JavaScript creates an event when user clicks on a button. |
76 | 95 |
|
77 | 96 |
|
78 | | -**CSS** |
| 97 | +###CSS |
| 98 | + |
79 | 99 | Stands for Cascading Style Sheets. CSS describes how HTML elements are to be displayed on screen. It is presentation. |
80 | 100 |
|
81 | 101 |
|
82 | | -**HTML** |
| 102 | +###HTML |
| 103 | + |
83 | 104 | Stands for Hyper Text Markup Language. It is a structure of the elements on the page. |
84 | 105 |
|
85 | 106 |
|
86 | | -**DOM** |
| 107 | +###DOM |
| 108 | + |
87 | 109 | Stands for Document Object Model. It defines the logical structure of documents and the way a document is accessed and manipulated. |
88 | 110 |
|
89 | 111 |
|
90 | | -**scope** |
| 112 | +###scope |
| 113 | + |
91 | 114 | Scope is the set of variables, objects, and functions that you can access |
92 | 115 |
|
93 | 116 |
|
94 | | -**console** |
| 117 | +###console |
| 118 | + |
95 | 119 | A method of interacting with the system. In order to write to the browser console, you could use console.log(‘Hello World’). This would write Hello World in the browser console. |
96 | 120 |
|
0 commit comments