Read:06a | Javascript Intro
Textbook: Jon Duckett: HTML & CSS
JavaScript Tidbits
- HTML = content, CSS = presentation, JavaScript = behavior
- JS is plain text like HTML and CSS so no special tools needed to write the script
- Connect the JS script via a
<script>tag in the HTML body / it matters where you place this - Calling a method is using an object, a dot and the method() / Ex:
document.write(‘hello’); - Methods often have parameters (the values written in the parenthesis(‘hello’))
- To use a quote in a string you can use the escape key
/
JS Lingo
- Statements: are instructions and each one starts a new line; can be organized in code blocks and usually end with
; - Comments: Single line comments explaining the code is written with
//before the text (multi-line uses/* */) - Variables: declare them like this
var thing;, assign them using = Ex:thing = 3; - Names can’t start with a number, cannot use - or . and use camelCase
- Data Types: Numeric data (0.75), String data (“Hello”), Boolean Data (true/false)