Showing posts with label javascript training institute. Show all posts
Showing posts with label javascript training institute. Show all posts

Thursday, January 25, 2018

Types of Functions in JavaScript- A Very Easy Explanation

Web designing or UI Development is one of the best industry to join if you love challenges and want to lead a happy life. This industry is one of the top highly paying industry for youth. JavaScript is the key language either you are a web designer or UI developer. So, knowledge of JavaScript matters when you want to make your career here.

A function is a group of reusable code which can be called anywhere in your program. It eliminates the need of writing the same code repeatedly. It helps in writing modular codes. Mainly JavaScript has 2 types of functions:
  1. Built-in functions:
Already defined in the JavaScript language, we invoke them again and again.
Examples: window.alert( ), document.write( ), parseInt( ) etc.
  1. User-defined functions:
Custom functions defined by user.
Below, we will see how to define our own user-defined functions. 
1. Function Definition
Before we use a function, we need to define it.
Syntax:
function functioName(parameter-list)
{
  statements
 }

To define a function in JavaScript, use the function keyword, followed by a unique function name, a list of parameters (that can be empty), and a statement block surrounded by curly braces.
Example:
function sayHi()  
{  
      Var x=10;
            alert(x);  
}

This example above does not have any parameters.

2. Calling a Function
To call a function specify the function name with parenthesis in front of it in the body section. Similarly, a function can be called inside another user defined function too.

Syntax:

<script type="text/javascript">
function functionName( )  
{
 ….code to execute…..
 } </script>

<script type="text/javascript"> functionName(); <script>

Example:

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">  
function helloAlert( )
 {
alert("Hello World!");
}  
</script>
</head>
 <body>  
<script type="text/javascript">  
helloAlert();
<script>
</body> </html>

In the above example we have defined a function “helloAlert()”, this function is later called in the body of the code and outputs a pop up that says “Hello world”;
3. Function with Parameters/Arguments
When you call a function, you can pass along some values to it, these values are called parameters or arguments. Parameters are the variables we specify when we define the function. When the function is later called somewhere else in the code, arguments are the values passed as parameters. We can specify multiple parameters, separated by commas (,). The parameters then serve as variables that can be used inside the function.
Syntax:

function functionName( parameter1 , parameter2 . . . parameter n)
{ some code to be executed }

Example:

<script>
function Hello( user )
{ alert( "Hello " + user +”!”); }
</script> <script> welcome( "Rav" ); </script>


In this example, we define a function named Hello( ) that takes in one parameter, named user. When the function is called, we pass the argument "Rav”. The function above when invoked will display the message box "Hello Rav!" on the webpage.
4. Functions with a return Value
Sometimes you want your function to return a value back to where the call was made. This can be done by using return statement. When using return statement, the function returns the specified value. Return is an optional statement.
Syntax:
function returningFunc(parameter) { Result= …. Execute code… return result; }

Example:
<html>  
             <head>
<script type="text/javascript">
function concatStrings(first, last)
{
var full;
full = first + last;
return full;
}
function secondFunction()
{
var result;
result = concatStrings (‘raveen’, ‘anand’);
document.write(result );
}
</script>
</head>
Try above example we defined a function that takes two parameters and concatenates them before returning the resultant in the calling program.
5. Nested Functions
JavaScript allows function definitions to be nested within other functions as well. Still there is a restriction that function definitions may not appear within loops or conditionals. These restrictions on function definitions apply only to function declarations with the function statement.
  1. Scope of the nested function is limited to its parent function
  2. The inner functions can access its parent variables but not otherwise.
Syntax:
 
function outerFunction()
      { var a, d, e;
 function innerFunction()
   {  
var f;  
}  
innerFunction ();
 }  
OuterFunction();

Example:

function hypotenuse(a, b) { function square(x)
{
return x*x;
} return Math.sqrt(square(a) + square(b)); } hypotenuse(1,2); In the above example we are calculating the hypotenuse of 2 numbers. Formula for hypotenuse is , here we calculate the square of the numbers in a nested function “square” which tales a number as input and returns its square.
6. Anonymous Functions
anonymous function is a function that is declared without any name. These functions can be assigned to variables when they are created, which gives the same capabilities as using a name within the function head. One common use for anonymous functions is as arguments to other functions.

Example:
var anon = function() { alert('I am anonymous'); } anon();

Differences between creating a named function and an anonymous function :
An anonymous function assigned to a variable only exists and can only be called after the program executes the assignment.

Named functions can be accessed anywhere in a program.

Can change the value of a variable and
assign a different function to it at any point
Not flexible-fixed name
Self-executing anonymous functions or IIFE
Another use for anonymous functions is as self-executing functions. A self-executing anonymous function is a function that executes as soon as it’s created. To turn a normal anonymous function into a self-executing function, you wrap the anonymous function in parentheses and add a set of parentheses and a semicolon after it.

The benefit of using self-executing anonymous functions is that the variables you create inside of them are destroyed when the function exits. In this way, you can avoid conflicts between variable names, and you avoid holding variables in memory after they’re no longer needed.
var myVariable = "I live outside the function."; (function() {
var myVariable = "I live in this anonymous function"; document.write(myVariable);
})();
document.write(myVariable);

In the example above, we have a variable myVariable declared globally. We have an anonymous self-executing function using the same variable name. The output of this is
I live in this anonymous function. I live outside the function”
7. Functions as Closures in JavaScript
A closure is the local variable for a function, kept alive after the function has returned. It is a function having access to the parent scope, even after the parent function has closed. An inner function is defined within an outer function. When the outer function returns a reference to the inner function, the returned reference can still access the local data from the outer function.
function greetVisitor(phrase) {  
var welcome = phrase + "Folks!"; // Local variable
 var sayWelcome = function() {
  alert(welcome);
}
return sayWelcome;
} var personalGreeting = greetVisitor('Hi');
 personalGreeting(); // alerts "Hi Folks!"
 
Conclusion is that functions in JavaScript are must to know as they are the building blocks in it for a web designer. There are many types of functions, you will understand their importance as you will use them in your JavaScript courses. You can learn it separately from any training center or you can join a complete course in web designing from a reputed web designing institute.

Wednesday, October 26, 2016

JavaScript Training Institute in Delhi

ADMEC is one of the leading Web Design and Web Development Institutes in Delhi. Among the several professional courses it offers JavaScript Master Course which covers advanced JavaScript concepts. It provides a scholastic atmosphere for both national and international students. The course would help web development students to learn how to write JavaScript code in order to develop dynamic and functional web pages in web development.

JavaScript is the most popular, light and open source scripting language mainly used for creating dynamic websites. Website design is done using most basic technologies, HTML5, CSS3 and JavaScript. These technologies are supported and preferred by search engines to increase the ranking of web pages. Java Script adds the behavior to the static website to make it more attractive and meaningful.

Courses:

ADMEC is providing advanced level JavaScript certificate course for Web designers and UI developers.

1. JavaScript Master Course

JavaScript Master Course is a short term 2months long certificate course. This course is for students and professionals who want to gain advanced level training using advanced JavaScript's procedural and object oriented (OOJS) approaches. It will cover every method starting from script setup to advanced DOM and manipulation of HTML and CSS.

Duration: 2 months

Training Mode: Both classroom and online

Pre-Requisites: Knowledge of HTML and CSS

Topics Covered:

Course content can be broadly classified into below topics:
  • Introduction
  • JavaScript Core Language Reference
  • Document Object Reference
  • Object Oriented JavaScript
  • Events
  • Exercises & Projects
          a. Form Validation using JavaScript
          b. Development of Navigation 
          c. Basic Games Development   
          d. E-learning Applications
          f. Image Galleries
          g. Slideshows
          h. Attractive Pop-up windows
          i. Theme Changer with JavaScript’s cookies
          j.  Accordion, Tabbed Panel, Go to Top Feature

2. JavaScript Master Plus Course

JavaScript Master Plus Course is a 3 months most comprehensive and advanced certificate course of JavaScript for JavaScript enthusiastics. This course is for students and professionals who want to gain advanced level programming with JavaScript language for building interactive user interfaces or UI for web pages and apps. It will train web designers and UI developers for the use of JavaScript and related debugging tools in the browsers, advanced functions, DOM manipulation, events, Object Oriented JavaScript, JavaScript Design Patterns, Ajax, JSON.

Duration: 3 months

Training Mode: Both classroom and online

Pre-requisites: Knowledge of HTML and CSS, Someone who wants to know all the nuts and bolts of Object Oriented JavaScript or OOJS and Design Patterns too along with all the basics of JavaScript.

Topics Covered:

Course content can be broadly classified into below topics:
  • JavaScript Basic Concepts
  • DOM & BOM
  • Events
  • Date & Cookie
  • Document Object Reference
  • Advanced JavaScript
            a. Object Oriented JavaScript
            b. Design Patterns etc

For any further information regarding our web design and web development courses, feel free to get in touch with our counselors at info@admecindia.co.in or call +91 (0) 981 181 8122. For a free demo, please note down the following details.

Skype Username: admec.multimedia.institute TeamViewer ID: 1 063 191 556

Wednesday, August 3, 2016

jQuery vs. JavaScript: Which One is Better

In beginning many web developers were confused about the term jQuery and JavaScript. And they are aware to know what is actually difference between jQuery and JavaScript. But they may surprise to know that both are same. Generally jQuery is a set of JavaScript API, which is designed to simplify HTML document traversing, animation, event handling and Ajax interactions.

But according to our choice to be a professional developer you must have a solid command over JavaScript. If you are not aware about using JavaScript for website development, check out Javascript MasterCourse. Once you aware about JavaScript Language, you might analyze that jQuery Master Course fulfill most of your requirements and it's requires less coding than conventional JavaScript may require.

Introduction of JavaScript

JavaScript is scripting language which is developed to use within web browser. It is widely used for interface interactions. Slides show and another interactive components can easily done using this language.

JavaScript also widely used in creating game development, web applications, server side programming etc. New standards in JavaScript forces all web browsers to implement JavaScript formally, which reduces developers time and frustration trying to debug code for a specific web browsing client.

jQuery Introduction:
In early days when jQuery was not developed, web developer created their own frameworks in JavScript. These frameworks allowed developers to work around some specific bugs without wasting of time. Later a group of developers created JavaScript libraries, which was open source and free of cost and generally called JavaScript libraries.

So jQuery is a library of JavaScript developed by John Resig. It is easy to use and extremely powerful in comparison to other JavaScript libraries.

Which one is better?
Developer spend lot of time debating whether jQuery or JavaScript is best???? But the truth is that there is no correct answer of this question.... Either can be selected for development point of view, because whatever effects we perform using JavaScript, that effects can achieve using jQuery.
Some web development projects require traditional JavaScript, however jQuery is sufficient for most web development projects. Although jQuery may be preferably a choice for experienced developer, but as a fresher web developer should still take the time to learn both JavaScript and jQuery.

One biggest difference between jQuery and JavaScript is that jQuery has been optimized to support variety of browsers automatically. But Unfortunately JavaScript still has some issues with cross-browser compatibility due to poor JavaScript implementation.

Example:
jQuery

$ (‘body’) .css (‘background’, ‘#ccc’);

JavaScript

Function changeBachground(color) {
document.body.style.background = color;
//or
document.bgColor = color;
}
window.onload= “changeBackground (‘red’)”;

A single line of code accomplishes same result in jQuery, what it take 4 lines of JavaScript code.

Wednesday, May 18, 2016

Advance JavaScript Training Institute in Delhi, India

Are you looking to grasp your knowledge in JavaScript? If yes, our advanced JavaScript training at ADME Multimedia Institute, is just what you need. This Course available on a full time, weekend and only Sunday. This course content includes online tools and study material.

The Advanced JavaScript course at ADMEC consists of using online tools and study material. Our Advanced JavaScript training starts from beginning to an advanced level. Our instructor aims to develop confidence within you using the latest tools and techniques required during the JavaScript training process.

During Advanced JavaScript course at ADMEC students will be able to spend one-to-one time with our instructor during doubt session. Our institute organizes weekly doubt session and classroom test to clear topics covered in previous classes. This process develops confidence between faculty and student to check.

Prerequisites to Join JavaScript Course at ADMEC Multimedia Institute

If you have a basic knowledge of HTML and CSS than, you can easily grasp your knowledge in JavaScript after the joining our advance JavaScript course. Apart from these, if you have a knowledge in latest version of HTML and CSS I.e HTML5 and CSS3, then it will be an extra added advantage for you. Our Institute offer HTML5 and CSS3 training also.

Our Online and Classroom Training Process

Regular Batch
  • Monday , Wednesday, Friday (1½ hrs)
  • Tuesday, Thursday, Saturday (1½ hrs)
Weekend Training
  • Saturday, Sunday (2 hrs)
  • Only Sunday (2-3 hrs)

Tuesday, June 2, 2015

Functions in JavaScript

Functions in JavaScript are one of the most important building blocks to know to become a master of JavaScript. Yesterday when I was teaching function in JavaScript to one of my batch then I thought to write something on it.

I think understanding of JavaScript becomes more important in JavaScript than any other programming in the world because JavaScript supports prototypical architecture of doing programming and prototypical approach can only be managed if you know JavaScript's functions in depth.

JavaScript can be written in a HTML page as browser understands it very well. You can make a separate JavaScript file and attach that in HTML using <script type="text/javascript" src=""></script> tag too.

Have a look on the following given JavaScript code please: 

function main(){
    alert('hello Ravi');
}
    //calling the function
    //main(); //you will get an alert when you will refresh your html page.
    //calling main() function on onclick event
    document.getElementById('mydiv').onclick = main;

Note: Don't use parenthesis () after the main function when you are calling a function on onclick event because function will not wait for the onclick event and it will be executed as you will load the html page.

How to pass parameters to a Function
Function's parameter is a way to make a function reusable and flexible. In the following example of code I have passed a parameter to main function and after that I have called twice and you can notice that you will get two different results while we have one function.

Function's parameter is a way to make a function reusable and flexible. In the following example of code I have passed a parameter to main function and after that I have called twice and you can notice that you will get two different results while we have one function.

Example 1:
function main(param){
    alert(param);
}
main('hello Ravi');// hello Ravi
main('hello admec multimedia institute');//hello admec multimedia institute

Example 2:
function main(param1, param2){
    return 'Hello '+param1+'\n Happy to meet you '+param2;
}
alert(main('Ravi', 'again'));
confirm(main('admec multimedia institute', 'first time'));
//document.getElementById('mydiv').onclick = main;// you will get error here*
//document.getElementById('mydiv2').onclick = main;// you will get error here*

*Why Error: As I set two parameters in main function and when you will call the function then surely you need to pass their values too and if I will pass the values then I need to add the parentheses () just next to the main function. But when I will add them then function will not wait for the onclick event as I said earlier and it will be called automatically as you will refresh the page. So the best way to handle this situation is the use of anonymous function. See the example below

document.getElementById('mydiv').onclick = function (){
    alert(main('Ravi', 'again'));
}
document.getElementById('mydiv2').onclick = function (){
        this.innerHTML = main('admec multimedia institute', 'first time');
}

Use of return in Function

return makes a function more flexible and reusable. If you want to display the results coming from a function on multiple locations then always use return in your function. See the below given example please: 

function main(param1, param2){
    return 'Hello '+param1+'\n Happy to meet you '+param2;
}


document.getElementById('mydiv').onclick = function (){
    alert(main('Ravi', 'again'));
}
document.getElementById('mydiv2').onclick = function (){
        this.innerHTML = main('admec multimedia institute', 'first time');
}

Managing Scope in Functions

Scopes in JavaScript are two types of: 
1. Global 
2. Local. 
When you declare any variable and function inside a function then that is in local scope of that function meaning you can only and only access those variables and functions inside that function only.

See the following example; the function nested is accessing all the variables and parameters whether they are inside its parent function or outside of that.
var global = 5;
function main(param1, param2)
{
    var parentLocal = 6;
    function nested(arg1){
        var childLocal = 3;
        return     param1 + param2 + arg1 + global + parentLocal + childLocal;
    }
    return nested(30);
}

alert(main(10,20));

Note: Scope in JavaScript runs from bottom to top.

Interested students can complete JavaScript training online from ADMEC Multimedia Institute.


Featured Post

ADMEC Multimedia Institute Scholarship Program

The ADMEC Multimedia Institute scholarship program aims to select and trained talented non working female, married woman and non married m...