Kowhai

Technical Blog Part 6. JavaScript Syntax


<ul class="post-10"> <li> <b>parentheses <code>()</code></b>:<br> <ul class="post-10"> <li>to wrap function arguments <code>function(p1, ..., pn)</code>,</li> <li>to group expressions <code>a = (7 - 2) * 4</code>,</li> <li>to wrap expressions/conditions <code>if (i <= 5)</code>,</li> <li>to wrap a list of parameters <code>myFunction(10, 15);</code></li> </ul> </li> <li> <b> brackets <code>[]</code></b>:<br> <ul class="post-10"> <li>to wrap array elements: <code>var myArray = [kowhai, pohutukawa, manuka];</code> </li> </ul> </li> <li> <b> braces <code>{}</code></b>:<br> <ul class="post-10"> <li> to declare Object Literals: <code>var manukaTree = {flower: "white"};</code> </li> <li> to wrap function definitions, conditional blocks, loops: <code>if (var tree === "pohutukawa") {<br> alert("Christmas is coming");</br>}</code></li> </ul> </li> <li> <b> single quotes <code>' '</code></b> and <b>double quotes <code>" "</code></b>:<br> <ul class="post-10"> <li> to declare a string: <code>var tree = "kowhai";</code>. </li> </ul> </li> </ul>

User's comments

Add a comment