Javascript Flashcards

1
Q
  1. HTML to define the _______
  2. CSS to specify the _______
  3. JavaScript to program the _______
A
  1. content of web pages
  2. layout of web pages
  3. behavior of web pages
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Javascript Syntax:

A

p id=”demo”

<script>
document.getElementById("demo").innerHTML = "My First JavaScript";
</script>
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

p id=”_____”

button type=”button” _______=”myFunction()”

<_____>
function _____() {
document.getElementById(“demo”)._________= “Paragraph changed.”;
}
</_____>

A

p id=”demo”

button type=”button” onclick=”myFunction()”

<script>
function myFunction() {
  document.getElementById("demo").innerHTML = "Paragraph changed.";
}
</script>
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

External JavaScript:
Scripts can also be placed in external files:

A

script src=”myScript.js” script

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

To access an HTML element, JavaScript can use the __________ method.

A

document.getElementById(id)

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

The innerHTML property defines the ___________

A

HTML content

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

window.alert() use:

A

You can use an alert box to display data.
You can skip the window keyword. It is Optional.
alert()

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

For debugging purposes, you can call the __________ method in the browser to display data.

A

console.log()

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

How to print the content of the current window in javascript?

A

button onclick=”window.print()”

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

JavaScript uses the keywords ________ to declare variables.

A

var, let and const
let x;
x = 6;

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

Code after double slashes ___ or between________ is treated as a comment.

A

//
/* and */

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

__________ are not allowed in JavaScript. They are reserved for subtractions.

A

Hyphens

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

‘Let’ keywords cannot be _____

A

Redeclared

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

Variables defined with ___ can be redeclared.

A

var

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

javascript variable declaration syntax:

A

p id=”demo”> /p

script
let person = “John Doe”, carName = “Volvo”, price = 200;
document.getElementById(“demo”).innerHTML = carName;
/script

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

A variable declared without a value will have the value ______

A

undefined

17
Q

let x = 2 + 3 + “5”;

Ans: ____

A

55
5 + “5” is string text so it will concatenate

18
Q

Variables declared with let have ______, must be Declared before use and cannot be Redeclared in the same scope.

A

Block Scope
{
let x = 2;
}
// x can NOT be used here

19
Q

Hoisting: Variables defined with var are hoisted to the top and can be initialized at any time.

A

Meaning: You can use the variable before it is declared:
carName = “Volvo”;
document.getElementById(“demo”).innerHTML = carName;
var carName;

20
Q

JavaScript has 8 Datatypes

A

String
Number
Bigint
Boolean
Undefined
Null
Symbol
Object

21
Q

JavaScript _____ operator to find the type of a JavaScript variable.

A

typeof
typeof “John Doe”; //string
typeof 314 // Returns “number”

22
Q

Exponential Notation
let y = 123e5; // _________
let z = 123e-5; // _______

A

12300000
0.00123

23
Q

All JavaScript numbers are stored in a ____ floating-point format.

A

64-bit

24
Q

JavaScript BigInt is a new datatype (ES2020) that can be used to store integer values that ____________ by a normal JavaScript Number.

A

are too big to be represented

25
Q

A JavaScript function is a block of code designed to perform a ___________

A

particular task.

26
Q

A JavaScript function is defined with the _______ keyword, followed by a _____, followed by _____________.

A

function
name
parentheses ()
function name(parameter1, parameter2, parameter3) {
// code to be executed
}

27
Q

It is a common practice to declare objects with the ____ keyword.

A

const

28
Q

In JavaScript, almost “______” is an object.

A

everything
Objects are objects
Maths are objects
Functions are objects
Dates are objects
Arrays are objects

29
Q

A primitive value is a value that has __________

A

no properties or methods.
3.14 is a primitive value

30
Q

JavaScript defines 7 types of primitive data types:

A

string
number
boolean
null
undefined
symbol
bigint

31
Q

Objects are containers for _________

A

Properties and Methods.

32
Q
A