-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJavaScript Basics.txt
73 lines (54 loc) · 1.41 KB
/
JavaScript Basics.txt
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
JavaScript Basics
Number(var) //converts var into type number
alert("")
Printing
----------
console.log("")
Input
--------
var name = prompt("What is your first name? ")
Types
------
Number
String
Boolean
Undefined
Null
Symbol
Object
Comparisons
------------
!== #not equal to
=== #equal to
>= #greater than or equal to
<= #less than or equal to
< #less than
> #greator than
Variables
---------
var firstName
Conditionals
-------------
if
else
else if
Logical Operators
------------------
&& #and
|| #or
! #not
Logical & Operator
------------------
this.state.error && <p>{this.state.error}</p> // if this.state.error has a value then render the error to the screen, otherwise never show this element
Ternary Operator
----------------
Description: props.expense ? props.expense.description : '' // if props.expense exists (true) then we will set the value of description to props.expense.description. If it does not exist (false) then we will set it to an empty string
Functions
---------
var a = function name() {} //Function Expression
function name() {} //Function Declaration (BEST WAY)
return
parameters - placeholders for future arguments
arguments - functions execute against arguments
One of the rules of thumbs for a developer is "not to repeat yourself. Ideally I should want to make things as "efficient" as possible.
Add "arguments" to functions. This is how I make my function "extensible" and customizable.