In a previous post, (JavaScript != Java)… I had covered what JavaScript can do for a webpage and thanks to a great comment from @apexsutherland I now know the answers to the questions that I posed. Thanks again Alex! This post will be brief and cover the syntax of JavaScript.
I have started the book on C++ and that has greatly helped with my understanding of JavaScript (FYI: I will be posting again about the start of the C++ book and probably more on JavaScript as I learn more). Syntax to remember:
- Composed of statements that end can end with a ; or a line break
- Be mindful of capitalization because it is a case-sensitive language
- Single line comments start with //
- Multiple line comments start with /* and end with */
- Read the “=” as “is set to”
- Example : if (test condition) {value if true; value if false;} Note: does not have to have a value for a false return. Note: This is helpful for making sure web-to lead forms are completely and correctly filled out
- I need more time before I completely understand arrays – I see how they are set-up and know they are very important (saw them in action at Dreamforce with help from @jhoskins). Any suggestions?
To me, the syntax seemed very similar to C++. Now that I have started to learn about C++ it is greatly helping my comprehension of JavaScript and vice-versa for that matter! I am hoping it will help with arrays!
Welcome to cheat sheet #1. I am writing this to review what I have learned about HTML, XHTML, and CSS. Most of this is syntax that I needed to write down to help me remember!
HTML and XHTML:
- Elements:
- Identify parts of HTML using tags
- Tags come in pairs, start with <tag> and end with </tag>
- Elements that insert something look like <tag … />
- Anchor Elements:
- Inline elements, typically used for links… <a href=”link”>text</a>
- You can use the target attribute to tell the browser how to display the link; target= “_blank”
- Attributes:
- Information about an specific element
- Located within a tag and specify a value and look like this: attribute=”value” and can be in any order
- Comments:
- Start with <!- – and end with – – >
- Tag examples:
- <head>, </head>; <body>, </body>; <hn>, </hn>; <p>, </p>;
<meta (name” “)…(content” “)/>; <title>, </title>
CSS:
- Separates style from the structure of a webpage and keeps the style of a website consistent
- They can occur on the page (internal) on in a text file (external) that has to be referenced using the <link rel(relative- resides on your site) or href (not on your site) /> or you can use
the @import “link”; after the <style> but before any style rule - Syntax looks like , selector {property: value;} and you can include more than one property with a value as long as they maintain the structure of property: value;
- Can create a style class and they are written like this: element.class attribute (if associated with an element) or .class attribute if not
- Inheritence. Parent elements find their way to child elements – if you say the in the body tag that the text is blue, it will be blue unless it is changed using inline style changes