Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles by Rahul Sharma
35 articles
How to Delete Bookmarks in your Browser (Firefox, Chrome)
Bookmarks in web browsers allow you to save and quickly access your favorite websites. You can create a bookmark by visiting a page and pressing Ctrl+D, or by clicking the star icon in the address bar. However, over time you may want to delete bookmarks that are no longer needed. This tutorial will show you how to delete bookmarks in both Firefox and Chrome browsers using different methods. Method 1: Delete from Address Bar The quickest way to delete a bookmark is directly from the address bar when visiting the bookmarked page: In Firefox ...
Read MoreHow to Validate your Website Code?
Website development involves writing code in HTML, CSS, JavaScript and your chosen platform. Your website may look correct and responsive, but it could have internal validation issues that affect SEO, accessibility, and browser compatibility. The W3C (World Wide Web Consortium) provides several free tools to validate your website code and ensure it meets web standards. HTML5 Validation Validator.nu is the recommended validator for modern HTML5 documents. It also validates ARIA, SVG 1.1, and MathML 2.0. This tool checks your complete document and identifies where the markup doesn't follow the specified doctype. ...
Read MoreWhy avoid increment ("++") and decrement ("--") operators in JavaScript?
The increment (++) and decrement (--) operators in JavaScript can lead to confusing code and unexpected results due to their pre-increment and post-increment behavior. Understanding why they should be avoided helps write clearer, more maintainable code. Pre-increment vs Post-increment Confusion The main issue with increment operators is the difference between pre-increment (++a) and post-increment (a++), which can produce unexpected values in assignments: var a = 5; var b = ++a; // Pre-increment: a becomes ...
Read MoreHow do you check if a variable is an array in JavaScript?
JavaScript provides several methods to check if a variable is an array. The most reliable and recommended approach is Array.isArray(), though instanceof Array also works in most cases. Using Array.isArray() (Recommended) The Array.isArray() method is the standard and most reliable way to check if a variable is an array. var sports = ["tennis", "football", "cricket"]; var name = "John"; var obj = {a: 1, b: 2}; if (Array.isArray(sports)) { alert('sports is an Array!'); } else { alert('sports is not an array'); } if ...
Read MoreWhy is 'class' a reserved word in JavaScript?
The class keyword is a reserved word in JavaScript because it was designated as a "future reserved word" in ECMAScript 5 and later implemented in ECMAScript 6 (ES2015) to introduce class-based object-oriented programming. Future Reserved Words in ECMAScript 5 ECMAScript 5 specification defined several future reserved words to allow for possible language extensions: class enum extends super const export import These words were reserved in ECMAScript 5 even though they had no functionality yet, ensuring they would be available for future language features without breaking existing code. Implementation in ECMAScript 6 In ...
Read MoreHow to name variables in JavaScript?
Variables can be thought of as named containers. You can place data into these containers and then refer to the data simply by naming the container. While naming your variables in JavaScript, keep the following rules in mind. Variable Naming Rules You should not use any of the JavaScript reserved keywords as a variable name. These keywords are mentioned in the next section. For example, break or boolean variable names are not valid. JavaScript variable names should not start with a numeral (0-9). They must begin with a letter or an underscore character. For example, 123test ...
Read MoreVariable Hoisting in JavaScript
When you can use a JavaScript variable before it is declared, it is done using a technique called hoisting. The parser reads through the complete function before running it. The behavior in which a variable appears to be used before it is declared is known as hoisting. JavaScript moves variable declarations to the top of their scope during compilation. Example: var Hoisting For example, the following code works due to hoisting: points = 200; var points; console.log(points); 200 The above works the same as if you had written: ...
Read MoreWhat happens if we re-declare a variable in JavaScript?
When you re-declare a variable in JavaScript using var, the original value is preserved. The re-declaration doesn't reset or change the variable's value. Example Let's see an example where we declare the variable age twice: Variable Re-declaration Example var age = 20; var age; // Re-declaration without assignment ...
Read MoreHow to write inline JavaScript code in HTML page?
Inline JavaScript refers to JavaScript code written directly within an HTML document using tags, rather than linking to an external JavaScript file. This approach is useful for small scripts or page-specific functionality. Syntax To write inline JavaScript, place your code between opening and closing tags: // Your JavaScript code here Example: Basic Inline JavaScript Inline JavaScript Example Welcome to My Page Click Me ...
Read MoreHow to use the same JavaScript in multiple content pages?
To use the same JavaScript in multiple content pages, add the JavaScript code in an external JavaScript file. This approach promotes code reusability and easier maintenance across your website. Creating an External JavaScript File First, create an external JavaScript file. Let's say the following demo.js is our external JavaScript file: function display() { alert("Hello World!"); } function calculate(a, b) { return a + b; } function showMessage(message) { alert("Message: " + message); } Including External JavaScript in HTML Pages ...
Read More