Log into database: mysql [db_name]
View a table: SELECT * FROM table_name;
Update a record in a table:
UPDATE [table_name] SET [table_column] = NOW() WHERE id = 1;
| // JS has 5 data types that are assigned by value: | |
| // `Boolean`, `String`, `Number`, `null`, `undefined` (primitives) | |
| // JS has 3 data types that are assigned by reference: | |
| // `Array`, `Function`, `Object` (objects) | |
| var x = 1, y = '1', z = undefined; | |
| // When we assign these vars to other vars we copy the value to the new var | |
| var a = x, b = y, c = z; |
| // Anonymous function: | |
| // Ex.1 | |
| (function() { | |
| // We keep these variables private inside this closure scope | |
| var myGrades = [93, 95, 88, 0, 55, 91]; | |
| var average = function() { | |
| var total = myGrades.reduce(function(accumulator, item) { | |
| return accumulator + item; | |
| }, 0); | |
| return 'Your average grade is ' + total / myGrades.length + '.'; |
| // `bind` and `this` | |
| let dog = { | |
| sound: 'woof', | |
| talk: function() { | |
| console.log(this.sound); | |
| } | |
| } | |
| dog.talk(); // => 'woof' |
| // In JS `!!` can be used to convert any value to a boolean | |
| // Similar to using the Boolean() function | |
| (function() { | |
| var foo = 'foo'; | |
| console.log(typeof foo); | |
| var bool = !!foo; | |
| console.log(typeof bool); | |
| console.log(bool); |
| /** | |
| * check if vals are objects | |
| * if so. copy that object (deep copy) | |
| * else return the value | |
| */ | |
| function deepCopy(obj) { | |
| const keys = Object.keys(obj); | |
| const newObject = {}; | |
| for (let i = 0; i < keys.length; i++) { |