896+ Capstone Project is Available: Whatsapp: +91-7011258995, Email: sharecodepoint@gmail.com

JavaScript Tutorial : Introduction, Types of JavaScript, Syntax, Comments in javascript - JavaScript Part 1

Why javascript? 
JavaScript is a lightweight,high-level,dynamic and interpreted programming language. Alongside HTML and CSS, JavaScript is one of the core technologies Web Development. JavaScript is used to make webpages interactive.

Who can learn JavaScript?
One should have prior knowledge of HTML coding and some exposure to object-oriented programming concepts .

Types of JavaScript
Same as CSS JavaScript also of three types
1→External.
2→ Internal.
3→ Inline.

Note:- JavaScript accepts both double and single quotes.

Syntax:
Javascript can be implemented using javascript statements
that are placed within the
<script> .. </script>

Example:
<html>
  <body>
    <script> 
          document.write("Welcome to JavaScript !"); 
    </script> 
  </body> 
</html>
Output:
Welcome to JavaScript !

Usage of Semicolons:
In JavaScript semicolons are optional. Unlike C,C++,Java languages JavaScript allows you to omit this semicolon if each of your statements are placed on a separate line.

Example 1:
<html> 
  <body> 
     <script> 
            var a = 10 
            var 2 = 20 
                document.write(a) 
                document.write(b) 
     </script> 
   </body> 
</html>
Output :
1020

Example 2:
<html> 
     <body>
           <script >
                   var a = 10;
                   var 2 = 20;
                       document.write(a);
                       document.write(b);
            </script>
        </body> 
</html>
Output:
1020

The basic difference between example 1&2 was after each statement in the example 1 we didnt used semicolon,but in example 2 we used semicolon,basically the output was same in both the scenarios.

Note:- But it is not a good practice to ignore semicolons.

Case Sensitivity: 
JavaScript is a case-sensitive language. This means that language variables,keywords etc must always be typed consistent capitalization of letters.
Comments in javascript: 
1) Any text between a // and the end of the line will be treated as a comment and it will be ignored by JavaScript.
2) Any text between /* and */ will also be treated as a comment and that will be ignored by JavaScript.
3) Any text between <!-- and //-- > will also be treated as a comment and that will be ignored by JavaScript.

Example:
<html> 
   <body> 
      <script> 
           <!-- // This is a comment. used for single line comment same as c programming.
           /* * This is a multi line comment in JavaScript * It is also similar to comments in C Programming */ //-- > 
      </script> 
   </body> 
</html>


JavaScript Introduction Part 2 : Checkout

About Developer
Konakalla Premsai
I love to make things simple :)

Sharecodepoint

Sharecodepoint is the junction where every essential thing is shared for college students in the well-defined packets of codes. We are focused on providing you the best material package like Question papers, MCQ'S, and one NIGHT STUDY MATERIAL. facebook twitter youtube instagram

1 Comments

Previous Post Next Post

Contact Form