5.04.2016

Difference between java and javascript



Difference between java and javascript

Java and javascript are absolutely different both by concept and design. Javascript has nothing to do with java.




          In early days, Livewire is the nick named of  javascript, then it is named LiveScript when it was created by NetScape.
Facts says that it was called ECMAscript but it was renamed when Netscape passed it to the ECMA for more standard purpose.
          Moreover, javascript  is a client side, interpreted, object  oriented, high level scripting language.
          While java is a client side, complied, object oriented, high level language.

Understanding terminology
Client side:-Program is passed to the computer and computer uses browser to run them.
Server side:- Program run on the server and only result is passes to computer, which is also known when browser is on. For example php, jsp, asp, perl etc.
Interpreted:-The program source code is passed then all programing  language is visible. It is then converted into machine code. Java is dual half complied i.e. complied to the ‘byte code’, then executed in the virtual machine which convert it into almost complied code, inorder to execute in computer’s processor.

Scripting:- Scripting language are used for performing repetitive tasks. They donot handle complex program such as thread and memory management. They also donot create their own user interfaces instead rely on the program to create an interface for them. For example javascript.



5.03.2016

Javascript Example



Javascript Example
This is simple program to show current date and time
<!DOCTYPE html>

<html>

<body>

<h1>My First JavaScript</h1>

<button type="button"
onclick="document.getElementById('demo').innerHTML = Date()">
dear Click me to display Date and Time.</button>

<p id="demo"></p>

</body>

 </html>

Program to change the content of html text

<!DOCTYPE html>

<html>

<body>

<h1>What Can JavaScript Do?</h1>

<p id="demo">JavaScript will change HTML content.</p>

<button type="button"
onclick="document.getElementById('demo').innerHTML = 'Hello JavaScript!-i am the changed form.........'">
Click Me!</button>

</body>

 </html>



Stay happy with www.howiset.blogspot.com

5.02.2016

function in javascript


Function  in javascript
Function is nothing it  just  group the code of javascript, control structure, method calls, operation etc.
Function can be called on required, access it and run it. Thus, it reduce the redundancy of code in same script.
A function can be defined anywhere in the code. Javascript provide the several ways of defining them.
  • function declaration
  • function expression
  • function call
 Now let see example;;
<!DOCTYPE html>
<html>
<body>

<p>here this example calls a function , and returns the
result:</p>

<p id="devg"></p>

<script>
function myFunction(m, n) {
    return m* n;
}
document.getElementById("devg").innerHTML =
myFunction(1,23 );
</script>

</body>
</html>

This is the simplest example, follow  up for more info.
Stay happy with www.howiset.blogspot.com