This is a draft cheat sheet. It is a work in progress and is not finished yet.
Objects
Getting the value |
student.firstName
or student["firstName"]
|
Setting the value |
student.isSmart=true
|
Calling an object method |
student.fullName()
|
Delete |
|
Reassign Property Value |
object["property"] = "new value"
|
Math
Odd Number |
if (num % 2 == 1) { return true; }
|
Even Number |
if (num % 2 == 0) { return true; }
|
|
|
|
|
Arrays
substring() |
str.substring(indexStart, indexEnd) |
const test ='ABCDEFG' / test.substring(2,4) -> 'CD'
|
slice() |
str.slice(beginIndex, endIndex) |
charAt() |
str.charAt(index) |
const test = 'ABCD'; const index = 0; console.log("Index ${index} is ${test.charAt(index)}"); // expected output: "Index 0 is A"
|
|