5. What is JavaScript
Browser Only understands Html(Content) , CSS(styles), and
Javascript,
It’s a Scripting language, runs on client, gives the capability
to change HTML/CSS dynamically.
Initially used only from
Client Side Validations, Animations,DOM Manipulation
but now, we can develop Enire UI client with html,css,JS and
connect to backend using AJAX, JSON.
Jquery and MVC Frameworks like Backbone, Angular,Amber to
name a few are getting more popular.
6. Javascript Notes
Object Desc
OOPS In JS everything is an Object except
null,undefined,boolean,number and string.
window Top level object which repesents browser window. Has
document, history objs in it
http://www.w3schools.com/jsref/obj_window.asp
document Represent HTML Document
http://www.w3schools.com/jsref/dom_obj_document.asp
http://jsfiddle.net/mbhatamb/uXgEa/
DOM Document Object Model, Internal represetation of the html
document in browser.
http://csszengarden.com/
onLoad() Event http://jsfiddle.net/mbhatamb/Bq9Ke/
<body>, <frame>, <frameset>, <iframe>, <img>, <input
type="image">, <link>, <script>, <style>
7. Javascript Notes Contd.
Object Desc
When to Load Define the script at the end of body, while CSS in head
<html>
<link rel="stylesheet" type="text/css"
href="/css/normalize.css"/>
<body>
<html tags>..
<script > //your javascript</script>
</body>
</html>
Esp. 3rd Party Scripts
Operators 5==‘5’ for compare and 5===‘5’ (false) for strict compare
http://www.w3schools.com/js/js_comparisons.asp
Functions Vs
Function
Expressions
function myfunc(){ //body}; or var abc = function(){}.
(second is called as functionexpression, and cannot be
invoked until loadded. E.g
http://jsfiddle.net/mbhatamb/cX5CP/
8. Functions
Functions are first class objects in javascript.
Functions can have properties
You can store a function in a Variable
You can pass a function as a param to another function
You can have annonymous functions and function
expressions
9. Javascript Notes Contd.
Object Desc
closures Closure is the local variables for a function - kept alive after
the function has returned,
e.G http://jsfiddle.net/mbhatamb/pzXtd/
** Can be a good Challenge
Call() and apply()
methods
Special way to invoke methods in others Objects
pretending to be methods of our own object
http://jsfiddle.net/mbhatamb/ptjea/
** Can be a good Challenge
typeof var myvar=5 alert(typeof myvar) //alerts "number”.
Also used, if a javascript is not loaded e.g
http://jsfiddle.net/mbhatamb/VXMUP/
10. Quiz
Why do I need client side validation when Server side is there and vice versa.
What is DOM
Main methods to traverse DOM?
What is Window.onload() and Documend.onload()
When should I access my Document Object
When to load JavaScript and CSS
What are Global Variables
How to access Arguments of a function
What is arguments.callee()
What is Closures and Why?