Basics Flashcards
What is console.log used for
Writing messages to the console log. Useful for debugging.
for example console.log(“first script called”)
How is JS integrated in the header
<script src=”script.js” type=”text/javascript”></script>
Where are the 3 areas where javascript code can be positioned?
1) As a separate file and reference in the header
2) With in the header area
3) Within the <body> area
How is JS integrated in the header area?
<script type=”text/javascript”></script>
How is JS integrated in the body area?
<script type=”text/javascript”></script>
How are single line comments added in JS?
//
How are multiline comments added in JS
/*………
…..*/
How are functions defined in JS?
Functions are defined by the keyword FUNCTION. Followed by the function name and ( ).
The actual function is enclosed in { }
Example
function bob( ) {
actual function goes here }
How would function bob be called after it is defined?
bob( );
What 9 keywords cannot be used as function names?
switch
case
break
if
else
for
function
try
catch
How is a value returned from a function?
var added = add(5,5);
function add(a,b) {
var y = a + b;
return y;
};
added would = 10
How are arguments provided to a function?
Within the function call parentheses
bob(var1,var2)
How is each element of a web page referenced
As an object
How is a new object created?
Var myobj = new Myobject( );
Name 5 of the predefined objects
Window
Date
Math
String
Array