View on GitHub

reading-notes

Before scripting

HTML, CSS and JavaScript work together to make webpages come to life. You start with HTML, this is the structure of your website. Then you add CSS to it, this styles the webpage, which is adding colors to things, adding backgrounds and similar. Then you add JavaScript to the mix, this adds interactivity to the webpage.

Keeping each one of them in a separate file is the better practice.

All of those languages can be written in plain text. You can use JavaScript in two ways, first one is to add a <script></script> tag to HTML and code JavaScript inside it, the second way (and the better one) is to add a <script src:"js-file.js"> to your HTML, allowing you to link to the jS file. this means JavaScript won’t change the sourcecode, it’s just on top of it. Usually, the best place to put the <script> tags is at the end of the <body> tag in the HTML file.

Scripting

A script is a series of instructions that a computer can follow. Each individual instruction is known as a statement, and those end with a semicolon ;.

Dont forget, JavaScript is case sensitive

You can group any number of statements together by using what’s called a code block, which are statements inside curly brackets {}. There’s also something called variables, which are identification names or numbers, so you the computer (and you) can know what data are you talking about. As the name suggests, these can be changed at will. Making variables is easy, you just have to write var and then write the name of the variable, followed by a semicolon (or other code). It should look like something like this: var visiter_age;. Giving the variable a value is also easy, just use the equal = sign, it should look like something like this: visiter_age = 25, and now the visiter_age is 25. There are a few rules for naming variables, like:





102              
Home read01 read02 read03 read04 read05 read06 read07