An Introduction to JavaScript Flashcards

(37 cards)

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

20
Q

js method to return as fixed-point notation

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

24
Q

how to call a self written js file in same directory

A

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

25
how to log to console in js
console.log()
26
is js whitespace sensative
no
27
define a variable in js
var x=1;
28
js array
var friends=["nick","jim","brian"];
29
js array methods
.length= how many in an array
30
js array can hold another array t/f
t
31
in js if you access an index outside of array max index,
it returns undefined
32
js object has what
key pairs and values, an object is a lot like an array, but is assigned to a key
33
declare a js array
var me{first_name: "x", last name: "y"}
34
how to access an attr of an array in js
var's name.[key] like: | me.first_name;
35
store an object in an object
var me{"Employee Number":1}//wont work without quotes... to access use me["Employee Number"] //again the quotes are important here
36
change property in js array
me.first_name="z";
37
what chracter is used to declare an object
{ }