Javascript Flashcards

(19 cards)

1
Q

Javascript

A

– It is a client- and server-side object-based scripting
language that is used to make interactive Web pages
– Itis the most commonly used scripting language to add
dynamism and interactivity to Web pages
– JavaScript, written on the client-side, executes on a client
browser, thereby reducing the load on the server

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

Javascript can be put

A

Inside the <head>
* Inside the <body>
* Using external javascript file
<script src=“even.js”></script>

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

Data types

A

– Undefined
var foo;
alert(foo); // This will open a dialog containing “undefined”.
– Null
var foo = null;
alert(foo); // This will open a dialog containing “null”.
– Numbers
* var foo = 5;
* alert(foo); // This will open a dialog containing “5”.
– Booleans (Ex: true, false)
* var foo = true;– Strings (Ex: “Raj”, “Sourya”)
– Array
* var foo = [5, “five”, “5”];
* alert( foo[0] ); // Alerts “5“
alert( foo[1] ); // Alerts “five”
alert( foo[2] ); // Also alerts “5”

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

==

A

Is equal to

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

!=

A

Is not equal to

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

===

A

Is identical to (equal to and of the same
data type)

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

!==

A

Is not identical to

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

>

A

Is greater than

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

> =

A

Is greater than or equal to

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

<

A

Is less than

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

<=

A

Is less than or equal to

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

Equal versus identical

A

– Example
* alert( “5” == 5 ); // This will alert “true”. They’re both
“5”.
* alert( “5” === 5 ); // This will alert “false”. They’re
both “5”, but they’re not the same data type.
* alert( “5” !== 5 ); // This will alert “true”, since they’re
not the same data type

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

Control flow statements

A

– Selection statements (if, if-else, switch)
– Loops (for, while, do-while)
– Jump statements (break, continue)

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

Functions

A
  • Native functions-
    alert(), confirm(), and prompt()
    These functions trigger browser-level dialog boxes
  • Custom functions
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Popup Boxes

A

– A popup box is a window that displays a message along with an OK
button
– It may also contain a Cancel button
– It can prompt users to enter some text

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

JavaScript supports three types of popup boxes:

A

– The alert box
* Generally used to display an alert message while executing the JavaScript
code
* Used to display error messages after we validate a form
– The confirm box
* Advanced form of the alert box
* Displays a dialog box with two buttons, OK and Cancel
– The prompt box
* Used to input a value from a user
* It contains a text box and OK and Cancel buttons

17
Q

Events

A
  • An event is an action that can be detected
    with JavaScript.
  • Event binding
  • In javascript, an event is identified by an
    event handler.
18
Q

Types of event handler:

A

– onclick handler triggers a script when the user
clicks.
– the onload event handler triggers a script when
the document is loaded.
– onmouseover handler triggers a script when the
user mouses over an element.

19
Q

There are three common methods for applying
event handlers to items within our pages:

A

– As an HTML attribute (we may use it)
– As a method attached to the element (we may use
it)
– Using addEventListener
* In latter two approaches, we’ll use the window object.