Javascript Basics

44 cards   |   Total Attempts: 189
  

Related Topics

Cards In This Set

Front Back
How do you include JavaScript in your project?
You can inline your Javascript between <script> tags in an html document or you can import an external javascript file with the src option.<script src="/path/to/example.js"></script>
Why might you put your JavaScript includes at the bottom of the <body> tag?
To allow the page's DOM to fully load. By using this special function your scripts will always wait for the DOM to be fully constructed before acting.$(document).ready()
What is “JS Bin“?
It is an online editor. You can place HTML, CSS, and JS it in and run them to test ideas and practice.
Where is the official JavaScript documentation located?
Mozilla Developer Network Reference
Are semicolons required?
Semi-colons are required at the end of every line.
Are curly braces required?
Curly braces are required around object bodies and function bodies (with the exception of single-statement fat-arrow functions in ES6), and they're sometimes required around conditional and loop bodies. If a condition or loop has only one statement in its body, they're optional:
Are parentheses required for function invocation?
Parentheses are required for function invocation.
What's the difference between using var myVar = "foo"; and myVar = "foo";?
If you declare a variable without var the variable will be assigned to the global scope.
What's the difference between JS's undefined and null?
Undefined is the absence of a value. Null is an intentionally void value. Undefined == Null will result in true because both values are falsy. Use === to check instead.
How do you make an alert box pop up?
Alert("Hello");
How do you write to the console?
Console.log("Hi");
What can you put as keys in an Object in JavaScript?
Keys are always strings but you can omit the double quotes when assigning properties inside of curly braces.
What can you put as values?
Values can be any primitive data types but also other objects and functions.
What are two ways to get or set values to or from an object?
You can get or set an objects values using either bracket-notation or dot-notation.
In an object, is there a difference between using a plain text identifier like "myProperty"?
There is no difference.