It has nothing to do with java. Java script developed by Netscape in 1995 to create products and application that run in the browser.
Java script primarily run on the client side that means it doesn't need to run through server. It just need browser to run. Originally java script designed as a scripting language.
What can we do with JavaScript?
=>Make webpages more interactive
=>Validate the form at client side
=>Can change HTML content, attribute etc.
=>Infinite scrolling.
=> Parallax
=>Games in the browser
=>IOT (internet of things): robots , wearable tech and more..
How to declare variables ?
Use "var" keyword
Do not Use reserved keywords like char,final,for etc.
initial value is undefined i.e. false in this case.
Use "var" keyword
Do not Use reserved keywords like char,final,for etc.
initial value is undefined i.e. false in this case.
Java script is dynamic, functional, weak type-checked, object oriented, case sensitive and syntax is like c.
Data Types
Data Types
- boolean
- string
- number - 64 bit real
- object
Difference between for each loop of Javascript & (C# or VB).
JS - for (var i in collection) - i is an index here
C# or VB - foreach(var i in collection) - i is an item of collection
Java Script Operators
- && and ||
Explain : if object is null then it wont bother evaluating the second part as object is already null and assigned null to that variable.
var salary = salary || 5000;
Explain : if salary is undefined then default value is assigned i.e. 5000.
- = = = and != =
alert ( name = = = 0 ); gives false , it checks equality without type coercion.
JavaScript Function.
Function can return any value or return null.
Functions are objects that can be passed as parameters also.
Example:
var sum=0;
function Add()
{
sum + = 1;
return sum;
}
document.write(Add());
// output
1
JavaScript Closure.
Its an inner function that can use the local variable declared in the outer function.
Example:
// outer function
function OuterFunction(value)
{
var sum = 0; // local variable
// inner function
return function()
{
sum + = value; // local variable used by inner function
return sum;
}
}
var f = OuterFunction(2);
document.write(f());
document.write("");
document.write(f());
document.write("");
document.write(f());
document.write("");
document.write(f());
// output
2
4
6
8
What is DOM ?
DOM stands for Document Object Model and used for presenting HTML elements in the browser.
Thank you !!!
No comments:
Post a Comment