|
| 1 | +# JavaScript Cheatsheet |
| 2 | + |
| 3 | + |
| 4 | +**JavaScript (or JS)** |
| 5 | +It is a popular programming language commonly used to create interactive effects within web browsers |
| 6 | + |
| 7 | + |
| 8 | +**variable** |
| 9 | +A place to store values, can store any kind of information(data types): numbers, words, collections of data |
| 10 | + |
| 11 | + |
| 12 | +**undefined variable** |
| 13 | +A variable that has no value |
| 14 | + |
| 15 | +**to declare variable** |
| 16 | +To create a variable - done by using ‘ var variable-name = value ’ |
| 17 | + |
| 18 | + |
| 19 | +**to initialize variable** |
| 20 | +Set (give) some value to variable. |
| 21 | + |
| 22 | +**string** |
| 23 | +A set of characters, word, phrase. To initialize variable wit
10000
h a string you need to put this string into quotes. |
| 24 | + |
| 25 | +**boolean** |
| 26 | +Boolean variable represent a logical values True or False |
| 27 | + |
| 28 | + |
| 29 | +**array** |
| 30 | +An ordered list of values, can store different type of data inside |
| 31 | + |
| 32 | + |
| 33 | +**operator** |
| 34 | +Mathematical operators, such as: +, -, *, /, >, <, = etc |
| 35 | + |
| 36 | + |
| 37 | +**comments** |
| 38 | +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 | +Single line comment starts with // |
| 40 | +Multi line comment are placed between /* .. */ |
| 41 | + |
| 42 | + |
| 43 | +**function** |
| 44 | +A separable, reusable piece of code. It takes some input do some manipulation on it and return us output |
| 45 | + |
| 46 | + |
| 47 | +**to declare function** |
| 48 | +To create a function |
| 49 | + |
| 50 | +**argument** |
| 51 | +A value input that functions can accept |
| 52 | + |
| 53 | + |
| 54 | +**if/else statement** |
| 55 | +‘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 | + |
| 57 | + |
| 58 | +**while loop** |
| 59 | +It repeats code over and over again until some condition is met |
| 60 | + |
| 61 | + |
| 62 | +**for loop** |
| 63 | +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 | + |
| 65 | + |
| 66 | +**infinite loop** |
| 67 | +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 | + |
| 69 | + |
| 70 | +**object** |
| 71 | +A collection of properties |
| 72 | + |
| 73 | + |
| 74 | +**event** |
| 75 | +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 | + |
| 77 | + |
| 78 | +**CSS** |
| 79 | +Stands for Cascading Style Sheets. CSS describes how HTML elements are to be displayed on screen. It is presentation. |
| 80 | + |
| 81 | + |
| 82 | +**HTML** |
| 83 | +Stands for Hyper Text Markup Language. It is a structure of the elements on the page. |
| 84 | + |
| 85 | + |
| 86 | +**DOM** |
| 87 | +Stands for Document Object Model. It defines the logical structure of documents and the way a document is accessed and manipulated. |
| 88 | + |
| 89 | + |
| 90 | +**scope** |
| 91 | +Scope is the set of variables, objects, and functions that you can access |
| 92 | + |
| 93 | + |
| 94 | +**console** |
| 95 | + 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 | + |
0 commit comments