Skip to main content

Posts

Showing posts from May, 2017

Execption Handling in js

Hi every one,👋 Today I’m going to discuss about exceptions occur in java script. This is one of advance topic in java script and really important to have an idea about exception handling in js. First we move on to errors in java script. There are 3 types of errors in programming. Figure 1 Syntax errors occur when we miss any kind of syntax inside the codes. Like, Figure 2 Run time errors occur during execution. It bot because of any syntax errors. It happens like, trying to call a method but that method is not exist. Ex: <script type = “text/javascript”> document.getData(); </scrip> Logical errors are occur due to logical mistakes that happen by programmers. Because of these errors we can’t get the actual result that we need. When there is any run time error (exception) happen in the java script code we can handle them before the execution of the program. There are 3 types of handling ways ·      ...

void in java script

Hi, 👋 this is my 13 th JavaScript tutorial which is describe about void keyword in js. My previous tutorial is about math object in js. You can go through it too.👍 So I thought to explain about less heavy concept in here. Because last tutorials were so long. (But this is also an important concept) Ok let’s go to the point.👇 So we are going to learn about void keyword in js. What is void???💭 It is an important keyword which is not evaluate a return value.  That mean when we use void as java script function signature, then the function does not return any value. So it takes an expression of any type as its operand and returns undefined. OK. Let’s go to an example on js void. <html> <head> <title> java script void </title> </head> <body> <form name= my_form> <a href=”javascript:void (alert(‘Hi this is first void example !!!’))”>Clck here</a> </form> </body> </html> ...

For in loop in js

Hi so we are going to discuss about another loop statement. That is for in loop statement. You may wonder why I haven’t discussed about for in loop in simultaneously with other for loop. The reason is we must have an idea about objects in java scripts. Ok lets’ go to the lesson. This loop is go through the object properties. So this is very useful loop. The syntax is, for(variablename in object){         statement } So let’s see an example. This prints the web browser’s Navigator object. Figure 1 Figure 2 Let’s try with different object. <script> function myFunction() {     var me = {fname:"Chamini", lname:"Prashakthi"};     var word = "";     var x;     for (x in me) {         word += me[x] + " ";     }     document.getElementById("demo").innerHTML = word; } </script...

math object in java script

Hi, ✋ this is another new tutorial which is explain Math object in java script. Using math object we can access lots of mathematical constants and functions. So, let’s start math object.👇 Think you need to use the cos function. So you just have to type Math.cos(x). It’s simple! Here I have listed some Math properties.       À      Math.PI                 = this returns the value of π. (3.14)       À      Math.E                  = this returns the Euler’s constant. (2.718)       À      Math.LN2             = this returns the natural logarithm of 2. (0.693)       À      Math.LOG2E        = this...

java script Arrays

Hi everyone.👋 This is my 10 th js tutorial which is explain about Arrays in java script. If we consider an array as an object we can store multiple values of data in same type. This is the syntax for array var myArray = [“dog”,”cat”,”lion”,”monkey”,”tiger”]; or var myArray = new Array (“dog”,”cat”,”lion”,”monkey”,”tiger”); So according to this array elements can identify as myArray[0] = dog🐶 myArray[1] = cat🐱 myArray[2] = lion🦁 myArray[3] = monkey🐵 myArray[4] = tiger🐯 There are some properties of arrays that we can use them for various conditions. length property      = can get the array size index property       = can get the element that indexes from zero prototype property = this property allows to add properties and methods to any object Figure 1 This is the result: Figure 2 This prototype property is very important property in arrays. We can use it in various places which is used to add new p...

java script Objects (part two)

Hi this is my 9 th js tutorial and I hope to continue previous lesson which describe about objects. So we discussed how to create an object, how to initialize values to objects and object constructors. In this tutorial I hope to cover all the theories of js objects. So let’s move on!!! We can use methods to perform a task in js. (You know that in js functions tutorials) But without calling the function it is useless. So we can create object and call the function to perform the task or for given output. It is like this. Figure 1 Figure 2 We have lots of things to learn in js objects. This objects is the almost everything in js. As a beginning I hope this is enough for now and I hope to do more things using some examples future. Thank you✋!

javascript Objects (part one)

Hi, this is my 8 th js tutorial which describes about the objects in JavaScript. Objects are very serious topic and we must have clear idea about objects in js for advance developments. After this object tutorial we will move on to an existing example. So let’s move on…👉 If we consider object as a data type of js we can came to another judgment, it has five datatypes. Which means three primitive data types (numbers, string, Boolean), null and undefined data types. An object is a list of primitive data types. We can initialize values to object as arrays or we can leave them empty. If the value is   null   or   undefined , it will create and return an empty object, otherwise, it will return an object of a Type that corresponds to the given value. If the value is an object already, it will return the value. It is the simplest way to explain object. OK let’s move to create an object. This is a simple object … var my_object = {firstName:”Chamini”, secondNam...

java script Functions

Hi, how are you people? Hope everything is going well. So today lesson is about how to create js functions and some examples on js function. We have covered basic js theories there. So here onward we will move on to some advance points.👍 Ok this is js function. We can create js functions in different ways. Method 1 <script language= "javascript" type="text/javascript"> <!-- function function_name(argument set){      //function body } //--> </script> Method 2 (using constructor) <script language= "javascript" type="text/javascript"> var function_name = new Function("argument 1"," argument 2"," argument 3","functionbody;"); </script> Method 3 <script language= "javascript" type="text/javascript"> var function_name = function(arguments){      //function body } </script> Did you become mess on above code...