JavaScript Flashcards

1
Q

scripts

A

programs that accompany web pages.

Run in web browsers and make web pages more dynamic and powerful

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

variables

A

should start with lower case letter

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

displays in browser console

A

console.log()

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

displays on the web page

A

document.write()

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

mark the end of a statement

A

semicolon

optional unless we write multiple statements in a single line

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

comments

A
// single line
/*multi
line*/
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

open the console

A

Ctrl + Shift + J

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

javascript

A

programming language of the web

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

create a variable

A

var name/identifier = value;

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

undefined

A

a value

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

maximum number of decimal places JavaScript can handle

A

17

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

to know what type of data a variable contains

A

console.log(typeof(variable’s name));

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

data types

A

string
numbers
Boolean
object

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

special kind of comparison operator that requires the value and the type to be equal

A

===

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

logical and

logical or

A

&&

||

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

assign a value to a variable based on a condition being true or false

A

conditional operator

?

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

if non-boolean values have real value except 0, “”, undefined

A

when converted condition returns true

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

perform different actions based on different condition

A

conditional statements

if, switch

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

concatenate strings

A

string.concat(string);

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

to find how many characters a string have

A

string.length;

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

escaping character

A

\

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

extract a piece of string

A

slice(start, end);

substr(start, length);

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

replace

A

string.replace(search string, replace string);

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

change a string to use lower/upper case letters

A

string. toLowerCase();

string. toUpperCase():

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
multiplication and devision with a non-numeric string result in
NaN not a number but its type is number
26
casting
parstInt(string); | parseFloat(string);
27
round a number
Math.round(number);
28
Math.random();
produces a random number between 0 and 1
29
Date
date.getFullYear(); date.getMonth(); date.getDate(); date.getDay(); returns week day as a number from 0 to 6 toDateString();
30
special kind of variable that contains several values of a type or even different types
array great way to store related values var array_name = [content];
31
[ ]
array litteral
32
turns an array into a comma-separated string
array. toString(); | array. join();
33
a property that keeps track of number of values in the array
length
34
create arrays from strings
string.split(separator);
35
add values at the end of an array
array.push(value);
36
removes the last value from array
array.pop();
37
remove a value from the beginning of an array
array.shift();
38
add a value at the beginning of an array
array.unshift(value); | can use with multiple values
39
a method that can add, insert, replace and remove values
array.splice(index, how many values we want to remove, optional value to be added at the index);
40
sort an array
in alphabetical order - array.sort(); | reverse order - array.sort().reverse();
41
for loop
for(control_variable; condition; increment){statement;}
42
enhanced for loop
suppose thing is an array | for (var thing in things){......}
43
do while loop
runs at least one, even if the condition is false
44
skip specific iteration but continue loop
continue
45
find if a word ends with something
string.endsWith("text");
46
sample function definition
function sayHello(){console.log("Hello!");}
47
variables that contain several values or properties
objects
48
object literal
{ }
49
sample object
var person = {name:"Kajan", age:22, height:1.62};
50
if we want to get rid of a property
delete object.key;
51
defining a method
speak : function(){.........}
52
use ........... keyword to create as many instances of the object as we want
new
53
javascript can be placed in the ............. and the ............. sections of an HTML page
body | head
54
javascript display possibilites
writing into an alert box writing into an HTML output writing into an HTML element writing into the browser console
55
writing into an alert box
window.alert()
56
writing into an HTML output
document.write()
57
writing into an HTML element
using innerHTML
58
writing into the browser console
console.log()
59
javascript increases the speed by
validating user inputs before sending to the server and also reducing the load on the server
60
JavaScript code is written inside ............ of the html file you need to set the ............ attribute of the script to ...............
script tag type "text/javascript"
61
variables in javascript are declared using ........ keyword
var
62
in Javascript it is not required to specify the type of value a variable is going to hold
javascript itself takes care of it
63
variable name should start with
alphabet or underscore | cannot begin with numbers
64
javascript variables are .................
case sensitive
65
scope of javascript variable can be ............. or .............
local | global
66
a website might be just static content
web app would have dynamic content
67
the way javascript sees its containing pages' data
DOM - Document Object Model
68
render
to draw
69
display a message box with an OK button
alert()
70
display a message box which prompts for some user input
prompt(text, default_text)
71
display a dialog box with a message, ok and cancel button
confirm() | returns true if the user clicked ok
72
return true if the value and type of two variables are not equal
!==
73
conditional or ternary operators
checks a condition and based on the condition evaluates the value of a variable ?
74
bitwise and(&)
perform boolean AND operation on each bit of its variable
75
bitwise or
|
76
bitwise xor
^
77
bitwise not
~
78
left shift(<>)
to shift all bits in the first operand to left by the number of bits in the right operand
79
check whether a particular property is present within an object
in operator
80
check whether an object is an instance of the specified object
instanceof