JS Article

JavaScript

JavaScript is the world most popular lightweight, interpreted compiled programming language. It is also known as scripting language for web pages. It is well-known for the development of web pages, many non-browser environments also use it. JavaScript can be used for Client-side developments as well as Server-side developments.

Client-side:

It supplies objects to control a browser and its Document Object Model (DOM). Like if client-side extensions allow an application to place elements on an HTML form and respond to user events such as mouse clicks, form input, and page navigation. Useful libraries for the client-side are AngularJS, ReactJS, VueJS and so many others.

Server-side:

It supplies objects relevant to running JavaScript on a server. Like if the server-side extensions allow an application to communicate with a database, and provide continuity of information from one invocation to another of the application, or perform file manipulations on a server. The useful framework which is the most famous these days is node.js. JavaScript can be added to your HTML file in two ways:

Internal JS:

We can add JavaScript directly to our HTML file by writing the code inside the script tag. The script tag can either be placed inside the head or the body tag according to the requirement.

External JS:

We can write JavaScript code in other file having an extension .js and then link this file inside the head tag of the HTML file in which we want to add this code.

JavaScript Statements

The programming instructions written in a program in a programming language are known as statements. Order of execution of Statements is the same as they are written.

Semicolons:

1)Semicolons separate JavaScript statements. 2)Semicolon marks the end of a statement in javascript.

Code Blocks:

JavaScript statements can be grouped together inside curly brackets. Such groups are known as code blocks. The purpose of grouping is to define statements to be executed together.

White Space:

Javascript ignores multiple white spaces.

Line Length and Line Breaks:

Javascript code preferred line length by most programmers is upto 80 characters. The best place to break a code line in Javascript, if it doesn’t fits, is after an operator.

Keywords:

Keywords are reserved words and cannot be used as variable name.A Javascript keyword tells about what kind of operation it will perform.

JavaScript Syntax

JavaScript is a lightweight and dynamic computer programming language. It is used to create client-side dynamic pages. It is open-source and cross-platform language.

JavaScript Variables

A JavaScript variable is the simple name of storage location where data to be stored.

There are two types of variables in JavaScript which are listed below: --Local variables: Declare a variable inside of block or function. --Global variables: Declare a variable outside function or with a window object.

JavaScript Operator

JavaScript operators are symbols that are used to compute the value or in other word we can perform operations on operands. Arithmetic operators ( +, -, , / ) are used to compute the value and Assignment operator ( =, +=, %= ) are used to assign the values to variables.

JavaScript Expression

Expression is the combination of values, operators, and variables. It is used to compute the values.

JavaScript Comments

The comments are ignored by JavaScript compiler. It increases the readability of code. It adds suggestions, Information and warning of code. Anything written after double slashes // (single line comment) or between / and / (multi-line comment) is treated as comment and ignored by JavaScript compiler.

JavaScript Functions

JavaScript functions are the blocks of code used to perform some particular operations. JavaScript function is executed when something call it. It calls many times so the function is reusable.

Syntax:

          
            function functionName( par1, par2, ....., parn ) {
            // Function code
            }
            // JavaScript function can contain zero or more arguments.
          
        

Objects in Javascript

Objects, in JavaScript, is it’s most important data-type and forms the building blocks for modern JavaScript. These objects are quite different from JavaScript’s primitive data-types(Number, String, Boolean, null, undefined and symbol) in the sense that while these primitive data-types all store a single value each (depending on their types).

--Objects are more complex and each object may contain any combination of these primitive data-types as well as reference data-types. --An object, is a reference data type. Variables that are assigned a reference value are given a reference or a pointer to that value. That reference or pointer points to the location in memory where the object is stored. The variables don’t actually store the value. --Loosely speaking, objects in JavaScript may be defined as an unordered collection of related data, of primitive or reference types, in the form of “key: value” pairs. These keys can be variables or functions and are called properties and methods, respectively, in the context of an object. An object can be created with figure brackets {…} with an optional list of properties. A property is a “key: value” pair, where a key is a string (also called a “property name”), and value can be anything.

JavaScript Type Conversion

JavaScript is loosely typed language and most of the time operators automatically convert a value to the right type but there are also cases when we need to explicitly do type conversions. While JavaScript provides numerous ways to convert data from one type to another but there are two most common data conversions : Converting Values to String. Converting Values to Numbers.

JavaScript Reserved Words

In JavaScript you cannot use these reserved words as variables names, labels names or function names.

JavaScript Date Object Reference

The Date object in JavaScript is used to represent a moment of time. It is used to work with date and time.

FOR MORE INFORMATION "C" LANGUAGE GO TO THE VIDEO SECTION AND WATCH ANY VIDEO