JavaScript Introduction

JavaScript is a client-side scripting language. Javascript code is downloaded from the server and executed on client’s browser. We can include javascript statements in html file or we can create a javascript file and can import it on html files. In html file we can use script tag to write javascript statements. Syntax

we … Read more

Add active class onclick javascript and jQuery

Add active class to a div on javascript onclick event Here we are applying a style to a simple div. Steps to add a css class on click event

Add active class onclick javascript to HTML ul List to make menu Here We have ul list elements to create horizontal menu on click on … Read more

Type Conversion in JavaScript

Type Conversion in JavaScript means converting one data type to another. JavaScript data type or variables can be converted into a different variable and/or different data type by the following ways: Converting Numbers to Strings Using JavaScript method The JavaScript function String() can convert numbers into strings. String() can take any numbers, literals, variables, or expressions. Consider … Read more

Operator Precedence and associativity in JavaScript

Operator Precedence Operator precedence determines the order in which operators are evaluated when more than one operator is used in an expression. The higher an operator’s precedence, the earlier it is evaluated in comparison with the operators with lower precedence. Consider the following example:

The above expression is evaluated in the order of the … Read more

This Keyword in JavaScript

This keyword refers to an object, that object which is executing the current bit of JavaScript code. JavaScript function while executing has a reference to its current execution of any function, called this. JavaScript function while executing has a reference to its current execution of any function, called this. with this keyword, It does not matter how and where … Read more

JavaScript variables

Variable is a user given name to a memory location where user can store values and can access it using variable name. user can give any valid variable name to store data. Variables can store different types of data like integer,character,string, boolean,real values etc. Syntax

for all kind of variable we use var keyword … Read more

Hoisting in JavaScript

What is Hoisting? Hoisting is when the JavaScript interpreter moves all variable and function declarations to the top of the current scope. Hoisting is done during the interpreter’s first run through the code. The important thing is that the actual declarations are hoisted, and that assignments will be left where they are. Hoisting is a … Read more

JavaScript Syntax

JavaScript Keywords JavaScript keywords are some reserved words that can’t be used as identifier and are used to identify actions to be performed e.g., the var keyword tells the browser to declare variables in JavaScript. Here is the list of JavaScript keywords: abstract arguments await boolean break byte case catch char class const continue debugger default delete do double … Read more

Data Object in JavaScript

The Date object is a datatype, Date objects are created with the new Date( ), Most of “Date” methods simply allow you to get and set the year, month, day, hour, minute, second. If no arguments are provided, the constructor creates a JavaScript Date object for the current date and time according to system settings for timezone offset. … Read more

JavaScript Inclusion in HTML File

Javascript in Internal File You can place JavaScript code on HTML pages anywhere within<html> tags(within <body>tag as well as <head> tag) JavaScript code must be inside <script> tag for aninternal placement. Within <head> tag

Within <body> tag

External JavaScript To use JavaScript from an external file source, all JavaScript source code must be written … Read more