Basics Flashcards

1
Q

What is console.log used for

A

Writing messages to the console log. Useful for debugging.
for example console.log(“first script called”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How is JS integrated in the header

A

<script src=”script.js” type=”text/javascript”></script>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Where are the 3 areas where javascript code can be positioned?

A

1) As a separate file and reference in the header
2) With in the header area
3) Within the <body> area

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How is JS integrated in the header area?

A

<script type=”text/javascript”></script>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How is JS integrated in the body area?

A

<script type=”text/javascript”></script>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How are single line comments added in JS?

A

//

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How are multiline comments added in JS

A

/*………
…..*/

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How are functions defined in JS?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How would function bob be called after it is defined?

A

bob( );

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What 9 keywords cannot be used as function names?

A

switch
case
break
if
else
for
function
try
catch

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How is a value returned from a function?

A

var added = add(5,5);

function add(a,b) {
var y = a + b;
return y;
};

added would = 10

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How are arguments provided to a function?

A

Within the function call parentheses
bob(var1,var2)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How is each element of a web page referenced

A

As an object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How is a new object created?

A

Var myobj = new Myobject( );

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Name 5 of the predefined objects

A

Window
Date
Math
String
Array

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How are object methods and attributes referenced?

A

With a dot.

e.g oDate.getDate( )

17
Q

Name the 2 special objects that do not require the dot reference

A

Window and Console

18
Q

How are object context objects accessed?

A

Use “this”
this.objcont name

19
Q

How are variables pre-typed in JS?

A

They aren’t. All variables are assigned at runtime based on their content

20
Q

What is the difference in JS between var mynum = 123;
and var mynum = “123”;

A

123 is created as an integer

“123” is created as a string

21
Q

Once created, a variables type cannot change

A

False. It can change based on new contents

22
Q

Var is a required keyword when working with a variable in JS

A

False
var myvar = 3;
is equal to
myvar = 3;

23
Q

What happens if the VAR keyword is ommitted within a function?

A

The variable becomes a global variable

24
Q

In JS,
var myVar = 123;
is equivelent to
var myvar = 123;

A

False. JS is case dependent.

25
Q
A