JavaScript
Primitive Types
- Data Types
- Boolean
- Number
- String
- Null
- Undefined
Escaping Characters
'That email address isn\'t valid.'
typeof
- + addition
- - subtraction
- * multiplication
- / division
- % Modulus
Concatenation
"Hello, " + "World!
Logical Boolean
&& - and
|| - or
! - not
|| - or
! - not
Equal to and Not Equal
- == Equal in value
- === Equal in type and value
- != Not equal in value
- !== Not equal in type and value
- > greater than
- >= greater than
- < less than
- <= less than or equal to
Variables
var = "";
var x = 5,
var name = "Codeup", number = 23, ;
- break case catch class const continue debugger default delete
- do else export extends finally for function if import
- in instanceof new return super switch this throw
- try typeof var void while with yield
CONSTANT
const name = "Christian Parker
Shorthand Assignment Operators
+ plus
- Negation
++ Increment
-- Decrement
Working with Strings
Here are some useful functions to use when working with strings in JavaScript:
- .length: property that describes the number of characters in the string.
- .indexOf(char): returns the index of the specified character in the string.
- .replace(find, replace): returns a copy of the string after performing a substitution.
- .substring(fromIndex, toIndex): returns a subset of the original string based on the provided indices.
- .toUpperCase(): returns a copy of the string in all upper case.
- .toLowerCase(): returns a copy of the string in all lower case.
- .trim(): returns a copy of the string with whitespace at the beginning and end removed.
Javascript with HTML
<!DOCTYPE html>
<html>
<head>
<title>Inline JS</title>
</head>
<body>
<script> // JavaScript code goes here </script>
</body>
</html>
<html>
<head>
<title>Inline JS</title>
</head>
<body>
<script> // JavaScript code goes here </script>
</body>
</html>