Also make sure Js. is in an external file so you have the ability to debug. Go to the sources tab in your developer tools. Add two break points on the line items. And hit the play button.
Inline uses dedicated html tag called script. Want JS to run before the page loads then add to the head. If you want it to run after then add after the body. Browser renders page from the top down.
Reference a new file called script.js then go <script src=”file”></script> this typically is added after the body tag so it doesn’t cause render blocking. Now with HTTP2 you can still add it to the head you just need to add defer after the file name.
JS is case sensitive. Use camelCase. Variables start lowercase letter, objects and classes start with uppercase letter and constants are all-caps.
JS doesn’t care about white space but we humans should.
End each statement with a semicolon even though JS doesn’t require it.
Use comments liberally. Single line comments use two foreword slashes // and a multi line comment begins with /* and ends with */ (just like CSS)
React helps visualize data. React is declarative instead of imperative. Uses State and props. React developer tools as a browser extension.
In react essentially creating your own custom HTML elements and props are like attributes but you’re not limited to the attributes like id href src. Use props to give any attribute to any component.
When you drop the div out and just keep the <></> it’s called a react fragment.
Learn more about .useState and useEffect.
What are React Events?
You use className because class is a reserved class name.
Localstorage.getItem or .setItem
From learn webcode ten days of react: why react? The Dom is slow and there are issues with Dom local storage on page reload. The Dom approach has fragmented code and elements and it can be tough to mentally keep track of and babysit where different things are. The render-based approach or declarative approach is great but upon changes it renders the ENTIRE APP. React attempts to be he best of both worlds and is closer to the render-based approach. React is beautifully simple.
The browsers ability to work with raw JS data is blazingly fast.
Note: a smarter way to learn .com
/J’s/8.html #s on the top are PNG files. Cannot use on mobile.
I understand the importance of objects and even how constructure functions can make them easier to create. But how do you upload and store objects would imagine they live in a database preferably accessible via API but how do you get there?