An Introduction to JavaScript Flashcards

1
Q

javascript was created for what

A

scripting in the browser

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

is javascript dynamic

A

yes meaning you can update elements on the fly

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

javascript has properties of what two types of languages

A

oo and functional

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

can u use js server side?

A

yes

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

creating a javascript script

A

‘script type=”text/javascript”’

window.alert(“hi”);

‘/script’

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

what does the type signify in declaring a javascript type=”text/javascript”

A

that everything inside is of type javascript

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

good practice is to do what

A

put js code at end of page

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

write line in js

A

writeln();

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

declare a variable

A

var i=1;

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

can you execute a js file outside of a browser

A

yes, using something like jsdb

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

how to comment in js

A

single line //
multiline /*
*/
inline comments are available

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

global variable how to

A

omit the var and just assign a name to a value

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

how does var know its type

A

it is inferred based on what is passed to the variable

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

get the type of a variable

A

typeof x;

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

write a function in js with params and return value

A

function f(params){return params;}

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

what is the global context for js

A

the window object

17
Q

null

A

primitive type that represents the absence of a value– evaluates to false

18
Q

undefined

A

primitive type represents an unknown or unassigned value

returns when non-existant item is called upon

also evaluates to false

19
Q

js pi

A

PI

20
Q

js method to return as fixed-point notation

A

tofixed(3)

21
Q

how are methods invoked on objects etc

A

the dot i.e. PI.toFixed(3)

22
Q

Get input from user

A

Prompt()– you can ALSo concat this with hi+ prompt to output hi and input, and even wrap it in an alert

23
Q

If you are writing in a .js file do you need to specify that it’s a script

A

No

24
Q

how to call a self written js file in same directory

A

‘script src=”name.js”'’script’

25
Q

how to log to console in js

A

console.log()

26
Q

is js whitespace sensative

A

no

27
Q

define a variable in js

A

var x=1;

28
Q

js array

A

var friends=[“nick”,”jim”,”brian”];

29
Q

js array methods

A

.length= how many in an array

30
Q

js array can hold another array t/f

A

t

31
Q

in js if you access an index outside of array max index,

A

it returns undefined

32
Q

js object has what

A

key pairs and values, an object is a lot like an array, but is assigned to a key

33
Q

declare a js array

A

var me{first_name: “x”, last name: “y”}

34
Q

how to access an attr of an array in js

A

var’s name.[key] like:

me.first_name;

35
Q

store an object in an object

A

var me{“Employee Number”:1}//wont work without quotes… to access use me[“Employee Number”] //again the quotes are important here

36
Q

change property in js array

A

me.first_name=”z”;

37
Q

what chracter is used to declare an object

A

{ }