Menu Bar

JavaScript: Basic script

Chapter 1: Basics: Design a simple button on click of button display "hello javascript"
                     1. What is javascript
                     2. Why to use
                     3. Study how can javascript can change the HTML page
                     4. Where to Use: syntax
                     5. Case sensitive

Code: 
           

Output:
            
              

JavaScript: JavaScript is a scripting language, primarily used on the web. It is used to enhance HTML pages and is commonly found embedded in HTML code. JavaScript is an interpreted language. Thus, it doesn't need to be compiled. JavaScript renders web pages in an interactive and dynamic fashion. This allowing the pages to react to events, exhibit special effects, accept variable text, validate data, create cookies, detect a user's browser, etc.

JavaScript is the only language that can run both on the server and the browser. We need JavaScript to add interaction to website. Otherwise all sites would be mostly read only static text and images. There is some low level animation possible with CSS and HTML now but, for real functionality JavaScript is mandatory.

JavaScript can be placed in the body or in the head section of a HTML page, or in both. Scripts can also be placed in external files. External scripts are practical when the same code is used in many different web pages. JavaScript files have the file extension .js.

Syntax: <script>
             -----------
             </script>

JavaScript is case sensitive. All JavaScript identifiers are case sensitive. The variable lastName and lastname, are two different variables.











Chapter 2: Display Properties: Display an element value from javascript using below properties
                 1. Get element by id
                 2. Inner HTML
                 3. Document.write
                 4. Console.log
                 5. Window.alert

Code:
          

Output:
             

Code:
          

Output:
             

Code:
          

Output:
            
             

Code:
          

Output:
             








Chapter 3:
 Statements: Use all the below in a simple javascript page to display text and words.

                 1. Identifiers
                 2. Literals: display number and string literals
                 3. Variables: declare two variables and display the sum of two variables
                           a. Number
                           b. String
                           c. Arry
                           d. Undefined
                           e. null
                 4. Expressions
                 5. Comments
                           a. Single line
                           b. Multi line
                 6. JavaScript and Camel Case



JavaScript syntax defines two types of values: Fixed values and  variable values. Fixed values are called literals. Variable values are called variables.

JavaScript and Camel Case: Joining multiple words into one variable name.
          1. Upper Camel Case: FirstName, LastName etc.
          2. Lower Camel Case: firstName, lastName etc.


Code:
          
Output:
            

Code:
          
Output:
            

             
Code:
          

Output: