javascript Flashcards

1
Q

What is the advantage of external JavaScript?

A

Separates HTML and Code
Makes HTML and JavaScript easier to read and maintaiin
Cached JS files can speed up page loads

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

Name the four ways of JavaScript Display Possibilites :

A

console.log() -browser console
window.alert() -alert box
document.write() -html element
innerHTML

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

Write the code to change the id element named “demo” when the user clicks on a button.

A

<p>This will be changed</p>

Click

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

<h1>My First Web Page</h1>

<p>My First Paragraph.</p>

<p></p>

Insert the sum of 5+5 inside the p tag.

A
var a =document.getElementById("demo");
a.innerHTML = 5+5;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

The JavaScript programs are executed by what?

A

the web browsers

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

Can you name the javascript statements?

A
C : comment
O : operators
V : values
E : expressions
K : keywords
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the two types of JavaScript Values?

A

Fixed values and variable values.
fixed values : literals
variable values : variables

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

Name the ways you can declare variables

A

var, let and const

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

Difference between let and var?

A

var : known through out the function it is defined in

let : known thoughout the block it is defined in

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

Is JavaScript case sensitive?

A

Yes

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

What character set does javascript use?

A

Unicode

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

How do you debug in javascript?

A

All moderns browsers have a build in javascript debugger.

F12 and console

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

Name the 7 Javascript types.

A
Number
String
Boolean
function
Object
Null
Undefined
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How to create a javascript object?

A

var person ={firstname: “John”,

lastname: “Doe”,
age: 50};

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

What is the typeof undefined?

A

undefined

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

What is the datatype of null?

A

object

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

what is null=== undefined?

A

false

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

What is null==undefined?

A

true

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

can u declare string as objects?

A

NOPE DONT DO IT

20
Q

Create an object.

A
Var person =
{
 name : 'nilima',
great : 'very great'
};
21
Q

What are the scopes in javascript?

A

local and global

22
Q

What is a scope?

A

the set of variables, objects and functions you have access to.

23
Q

What are the event listeners?

A

<div></div>

element. onclick=function(){}
element. addEventListener(“click”, function(){});

24
Q

What does event.stopPropogation()?

A

it will stop calling event handlers.

25
Q

What does event.target do?

A

Always points to the lowest element on the tree it was clicked.

26
Q

What is bubble?

A

bubble starts at the bottom of the tree and works its way up

27
Q

What is capture/

A

starts at the top and goes to the button

28
Q

Name the string method to uppercase?

A

toUpperCase();

29
Q

Name the string method to lowercase?

A

toLowerCase()

30
Q

What returns the Maximum value?

A

MAX_VALUE

31
Q

What returns the Minimum value?

A

MIN_VALUE

32
Q

What does Math.pow() do?

A

Math.pow(2,2)

2 to the power 2 = 4

33
Q

What does Math.sqrt() do?

A

square root of

34
Q

What does Math.ceil do? Math.ceil(4.7)

A

5

35
Q

What does Math.floor do? Math.floor(4.7)

A

4

36
Q

What doe Math.random() return?

A

from 0 - 1 any number decimals

37
Q

How to sort array?

A

array.sort();

38
Q

How to reverse array?

A

array.reverse();

39
Q

How to handle errors?

A

like java try catch

40
Q

What is an error?

A

An object that has two properties named name and message.

41
Q

Name error name values

A

6 different values

  • EvalError
  • RangeError
  • ReferenceError
  • SyntaxError
  • TypeError
  • URIError
42
Q

what is ajax?

A

Asynchronous JavaScript and XML.
The ability to send request from JS asynchronously
u send the request forget about it and when you get the response you handle it

43
Q

Name the four steps in AJAX

A
  • create object
  • define onreadystatechange function
  • open request (method, url, async)
  • send request
44
Q

What does JQUERY have?

A

a single global object

$ and jQuery

45
Q

How to write ajax in jquery?

A
$.ajax({method: "get",
url:"some url",
success : function(){},
error : " ",
complete : "" })