javascript Flashcards
What is the advantage of external JavaScript?
Separates HTML and Code
Makes HTML and JavaScript easier to read and maintaiin
Cached JS files can speed up page loads
Name the four ways of JavaScript Display Possibilites :
console.log() -browser console
window.alert() -alert box
document.write() -html element
innerHTML
Write the code to change the id element named “demo” when the user clicks on a button.
<p>This will be changed</p>
Click
<h1>My First Web Page</h1>
<p>My First Paragraph.</p>
<p></p>
Insert the sum of 5+5 inside the p tag.
var a =document.getElementById("demo"); a.innerHTML = 5+5;
The JavaScript programs are executed by what?
the web browsers
Can you name the javascript statements?
C : comment O : operators V : values E : expressions K : keywords
What are the two types of JavaScript Values?
Fixed values and variable values.
fixed values : literals
variable values : variables
Name the ways you can declare variables
var, let and const
Difference between let and var?
var : known through out the function it is defined in
let : known thoughout the block it is defined in
Is JavaScript case sensitive?
Yes
What character set does javascript use?
Unicode
How do you debug in javascript?
All moderns browsers have a build in javascript debugger.
F12 and console
Name the 7 Javascript types.
Number String Boolean function Object Null Undefined
How to create a javascript object?
var person ={firstname: “John”,
lastname: “Doe”,
age: 50};
What is the typeof undefined?
undefined
What is the datatype of null?
object
what is null=== undefined?
false
What is null==undefined?
true
can u declare string as objects?
NOPE DONT DO IT
Create an object.
Var person = { name : 'nilima', great : 'very great' };
What are the scopes in javascript?
local and global
What is a scope?
the set of variables, objects and functions you have access to.
What are the event listeners?
<div></div>
element. onclick=function(){}
element. addEventListener(“click”, function(){});
What does event.stopPropogation()?
it will stop calling event handlers.
What does event.target do?
Always points to the lowest element on the tree it was clicked.
What is bubble?
bubble starts at the bottom of the tree and works its way up
What is capture/
starts at the top and goes to the button
Name the string method to uppercase?
toUpperCase();
Name the string method to lowercase?
toLowerCase()
What returns the Maximum value?
MAX_VALUE
What returns the Minimum value?
MIN_VALUE
What does Math.pow() do?
Math.pow(2,2)
2 to the power 2 = 4
What does Math.sqrt() do?
square root of
What does Math.ceil do? Math.ceil(4.7)
5
What does Math.floor do? Math.floor(4.7)
4
What doe Math.random() return?
from 0 - 1 any number decimals
How to sort array?
array.sort();
How to reverse array?
array.reverse();
How to handle errors?
like java try catch
What is an error?
An object that has two properties named name and message.
Name error name values
6 different values
- EvalError
- RangeError
- ReferenceError
- SyntaxError
- TypeError
- URIError
what is ajax?
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
Name the four steps in AJAX
- create object
- define onreadystatechange function
- open request (method, url, async)
- send request
What does JQUERY have?
a single global object
$ and jQuery
How to write ajax in jquery?
$.ajax({method: "get", url:"some url", success : function(){}, error : " ", complete : "" })