12 September 2023
I'm starting to think of HTML as a person, CSS as their wardrobe, and JavaScript as their fairy godmother who can make everything change with a wave of their wand.
JavaScript puts the extra pizzazz and sparkle into webpages - they make them more functional and interactive for people. And like magic, you can add/change anything about a website using JavaScript.
Control flow is essentially how a computer reads (a certain type of) code. Much like reading a book from left to right, and top to bottom, computers will complete the code from top to bottom also. However, there are exceptions. If it sees something like a loop, it will go back up and read the code again and again until it has met the requirements for that loop. An example of a loop in real life is eating breakfast. You start with a full bowl of porridge, and you place the spoon in your mouth, taking bits of porridge every turn until it is gone and the loop is complete.
The DOM stands for the Document Object Model. It is a strange looking family tree of only single parents that describes the skeleton framework of exactly how a webpage is put together. By using the DOM skeleton, you can pick a parent, child, sibling, cousin... and... modify them. You can do anything to them - make them bigger, smaller, sparklier, or... make them disappear.
Both arrays and objects collect data into a group. You can also use objects within arrays, and arrays within objects.
Arrays [] | Objects {} |
---|---|
Usually faster with small datasets | Usually better with large datasets |
For groups of data of same type/shape and has an order | For a single group with named properties, has no order |
Good when working with a set as a whole | Good when manipulating individual properties of the data |
Access the data by using the index e.g. array[0]. Or knowing exactly what data you are looking for. | Access the data by knowing exactly which property you require e.g. object.property. |
These are an incredibly useful bit of code for any activity that you want to call on again and again. Say, for example, you want to tell someone how you drive to work (with very detailed instructions) and there is a set path that you take every single day. If someone else asked how you get to work, and you had already turned this into a function, you could just press a button and give them your complete journey instructions.