| 1 |
** |
| 2 |
Simple conversation with user |
| 3 |
^ console.log() is basic command for conversation with user |
| 4 |
a) highlight > run code (ctrl + alt + N) |
| 5 |
` only this command we can test in code editor |
| 6 |
b) other commands only in browser |
| 7 |
^ alert() |
| 8 |
` in this command all other scripts stop till we press 'Ok' |
| 9 |
`the simplest command |
| 10 |
^ confirm() |
| 11 |
` if we output via console.log(let); then we press 'Ok'. it will be 'true', or else 'false' (boolean definition) |
| 12 |
^ variable is always without quotes |
| 13 |
^ for quicking commenting '//' |
| 14 |
` highlight necessary lines |
| 15 |
` ctrl + / |
| 16 |
^ prompt('something', 'default answer' or "") |
| 17 |
` "" it's for excluding showing errors in internet explorer |
| 18 |
^ all information from user alwas is 'string' |
| 19 |
` exception is massive (privat chance of object) |
| 20 |
` official mistake is null (it ouputs like object via tupof()) |
| 21 |
^ for learning type of data |
| 22 |
` typeof() |
| 23 |
** |
| 24 |
Operators in JS |
| 25 |
^ hot key |
| 26 |
a) type in other lines at the same time (alt+ctrl+down/upArrow) |
| 27 |
^ Basic operators are + - * / |
| 28 |
a) spesial is + |
| 29 |
` if 'string' + 'string', it's addition |
| 30 |
` if 'string' + number, number will be added to the 'string' (concatenation) |
| 31 |
` if before 'string' we put +'string', it will be number |
| 32 |
' it can be used in practise, e.g. using prompt (we want to get number from user, just adding +prompt()) |
| 33 |
^ next operators |
| 34 |
a) increment ++ and decrement -- |
| 35 |
` prefix form (++let) returns changeable definition |
| 36 |
` postfix form (let++) returns old definition |
| 37 |
b) % |
| 38 |
` it returns left from dividing of 2 numbers |
| 39 |
c) |
| 40 |
` = assignment |
| 41 |
` == equal |
| 42 |
` === strong equal including type of data |
| 43 |
d) && |
| 44 |
` it will return true if 2 or more arguments are "true", or else "false" |
| 45 |
e) || |
| 46 |
` it will return true if at least 1 argument is true, or else false |
| 47 |
` && and || often used in practise |
| 48 |
' we can check about ticking checkboxes in form |
| 49 |
' check size of screen |
| 50 |
' check: is modal window open? |
| 51 |
' others |
| 52 |
f) !argument |
| 53 |
` it changes definition from true in to false or vice versa |
| 54 |
^ we can just write once "let" |
| 55 |
a) type a lot of variables, but semicolon only after the last one |
| 56 |
b) between variables only comma |
| 57 |
c) every variable from new line |
| 58 |
d) e.g. let var1 = sth, |
| 59 |
var2 = sth, |
| 60 |
var = sth; |
| 61 |
^ 'use strict' |
| 62 |
a) it says that javascript uses version from es6 |
| 63 |
b) better determines mistakes |
| 64 |
c) doesn't work with IE9 and lower (can be solved) |
| 65 |
d) always use 'use strict' |
Комментарии