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
Q

multiplication and devision with a non-numeric string result in

A

NaN
not a number
but its type is number

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

casting

A

parstInt(string);

parseFloat(string);

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

round a number

A

Math.round(number);

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

Math.random();

A

produces a random number between 0 and 1

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

Date

A

date.getFullYear();
date.getMonth();
date.getDate();
date.getDay(); returns week day as a number from 0 to 6
toDateString();

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

special kind of variable that contains several values of a type or even different types

A

array
great way to store related values
var array_name = [content];

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

[ ]

A

array litteral

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

turns an array into a comma-separated string

A

array. toString();

array. join();

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

a property that keeps track of number of values in the array

A

length

34
Q

create arrays from strings

A

string.split(separator);

35
Q

add values at the end of an array

A

array.push(value);

36
Q

removes the last value from array

A

array.pop();

37
Q

remove a value from the beginning of an array

A

array.shift();

38
Q

add a value at the beginning of an array

A

array.unshift(value);

can use with multiple values

39
Q

a method that can add, insert, replace and remove values

A

array.splice(index, how many values we want to remove, optional value to be added at the index);

40
Q

sort an array

A

in alphabetical order - array.sort();

reverse order - array.sort().reverse();

41
Q

for loop

A

for(control_variable; condition; increment){statement;}

42
Q

enhanced for loop

A

suppose thing is an array

for (var thing in things){……}

43
Q

do while loop

A

runs at least one, even if the condition is false

44
Q

skip specific iteration but continue loop

A

continue

45
Q

find if a word ends with something

A

string.endsWith(“text”);

46
Q

sample function definition

A

function sayHello(){console.log(“Hello!”);}

47
Q

variables that contain several values or properties

A

objects

48
Q

object literal

A

{ }

49
Q

sample object

A

var person = {name:”Kajan”, age:22, height:1.62};

50
Q

if we want to get rid of a property

A

delete object.key;

51
Q

defining a method

A

speak : function(){………}

52
Q

use ……….. keyword to create as many instances of the object as we want

A

new

53
Q

javascript can be placed in the …………. and the …………. sections of an HTML page

A

body

head

54
Q

javascript display possibilites

A

writing into an alert box
writing into an HTML output
writing into an HTML element
writing into the browser console

55
Q

writing into an alert box

A

window.alert()

56
Q

writing into an HTML output

A

document.write()

57
Q

writing into an HTML element

A

using innerHTML

58
Q

writing into the browser console

A

console.log()

59
Q

javascript increases the speed by

A

validating user inputs before sending to the server and also reducing the load on the server

60
Q

JavaScript code is written inside ………… of the html file
you need to set the ………… attribute of the script to ……………

A

script tag
type
“text/javascript”

61
Q

variables in javascript are declared using …….. keyword

A

var

62
Q

in Javascript it is not required to specify the type of value a variable is going to hold

A

javascript itself takes care of it

63
Q

variable name should start with

A

alphabet or underscore

cannot begin with numbers

64
Q

javascript variables are ……………..

A

case sensitive

65
Q

scope of javascript variable can be …………. or ………….

A

local

global

66
Q

a website might be just static content

A

web app would have dynamic content

67
Q

the way javascript sees its containing pages’ data

A

DOM - Document Object Model

68
Q

render

A

to draw

69
Q

display a message box with an OK button

A

alert()

70
Q

display a message box which prompts for some user input

A

prompt(text, default_text)

71
Q

display a dialog box with a message, ok and cancel button

A

confirm()

returns true if the user clicked ok

72
Q

return true if the value and type of two variables are not equal

A

!==

73
Q

conditional or ternary operators

A

checks a condition and based on the condition evaluates the value of a variable
?

74
Q

bitwise and(&)

A

perform boolean AND operation on each bit of its variable

75
Q

bitwise or

A

|

76
Q

bitwise xor

A
77
Q

bitwise not

A

~

78
Q

left shift(<>)

A

to shift all bits in the first operand to left by the number of bits in the right operand

79
Q

check whether a particular property is present within an object

A

in operator

80
Q

check whether an object is an instance of the specified object

A

instanceof