Found 6710 Articles for Javascript

What is the difference between a method and a function?

Alshifa Hasnain
Updated on 17-Mar-2025 11:59:46

7K+ Views

In this article, we will learn about the difference between a method and a function in Javascript. Method and a function are the same, with different terms. A method is a procedure or function in object-oriented programming. What is a Function? A function is a group of reusable code that can be called anywhere in your program. This removes the necessity to repeat the same code over and over, assisting developers in writing modular code. JavaScript functions can be defined in a number of ways, such as function expressions, arrow functions, or the function keyword. The following is the syntax ... Read More

How can I remove the (//) blocks; tags inside a script element in Javascript?

Saurabh Jaiswal
Updated on 11-Aug-2022 11:30:45

760 Views

CDATA, the short form of Character Data is a block of code that has been written to prevent parsing by the parser. Sometimes our data includes predefined characters like “ Syntax str.replace("regex", "") Here str is the string from which you want to remove the CDATA, regex is the regular expression to find the block data. Example In the below program example, we remove the CDATA blocks and tags inside a script element using the String replace() method. We pass the regex defined above as an argument to the replace() method and the second argument is an empty string. ... Read More

What ECMAScript 6 features can I currently use in web browsers?

Giri Raju
Updated on 02-Jan-2020 09:41:54

211 Views

The full form of ECMA is European Computer Manufacturer's Association. ECMAScript is a Standard for scripting languages such as JavaScript, JScript, etc. It is a trademark scripting language specification. JavaScript is a language based on ECMAScript. A standard for scripting languages like JavaScript, JScript is ECMAScript. JavaScript is considered as one of the most popular implementations of ECMAScript.ECMAScript 6 is working fine on web browsers like Chrome, Microsoft Edge, Safari, etc:90% compatibility – Chrome 80% compatibility - Microsoft Edge54% compatibility – SafariUse ES6 using Babale pre-processor, which cross-compile JavaScript back to ECMAScript 5 compatible code.Here are features of ECMAScript 6:Arrow FunctionsDeclare ... Read More

Does a real ECMAScript implementation exist, or is it just a spec?

varma
Updated on 02-Jan-2020 09:03:25

269 Views

ECMAScript is a standard for JavaScript implementation. You cannot run or download ECMAScript. JavaScript 2.0 conforms to Edition 5 of the ECMAScript standard, and the difference between the two is minor.The 8th edition, known as ECMAScript 2017, came in June 2017. ECMAScript is a Standard for scripting languages such as JavaScript, JScript, etc. It is a trademark scripting language specification. JavaScript is a language based on ECMAScript. A standard for scripting languages like JavaScript, JScript is ECMAScript. JavaScript is considered as one of the most popular implementations of ECMAScript.The ECMA-262 Specification defined a standard version of the core JavaScript language.JavaScript ... Read More

JavaScript closures vs. anonymous functions

Alshifa Hasnain
Updated on 20-Feb-2025 18:25:54

677 Views

In this article, we will learn about JavaScript's closures and anonymous functions. JavaScript is a powerful language that allows developers to write expressive and concise code. Two concepts that often confuse beginners are closures and anonymous functions. While they share some similarities, they serve different purposes and function differently in JavaScript What is Anonymous Functions? An anonymous function is simply a function without a name. Anonymous, as the name suggests, allows the creation of a function without any name identifier. It can be used as an argument to other functions, assigned to a variable, or immediately invoked. They are called using ... Read More

What is the difference between call and apply in JavaScript?

varun
Updated on 02-Jan-2020 09:02:51

328 Views

In JavaScript, .call and .apply are considered a method of function object..call methodCount the number of arguments with call method. It accepts one or more arguments as objects.Here’s the syntax:.call(object, “argument1”, “argument2”);.apply method To use an array as an argument, use .apply. It requires an array as its 2nd argument.Here’s the syntax:.apply(object, [“argument1”, “argument[]”]);ExampleLet’s see an example showing both call and apply method:                                 var p = {                q: "Hello"             } ... Read More

When is a CDATA section necessary within a script tag?

Alshifa Hasnain
Updated on 20-Feb-2025 18:27:06

761 Views

When working with JavaScript inside HTML documents, developers may come across the CDATA section. It can be helpful when dealing with older XHTML documents or embedded JavaScript in XML-based markup. What is a CDATA Section? A CDATA (Character Data) section is a special syntax used in XML and XHTML documents to prevent certain characters from being interpreted as markup. It ensures that special characters like < and & are treated as plain text rather than triggering parsing errors. Syntax − Why Was CDATA Used tag? To avoid parsing the symbols &, it is added in …. It ... Read More

What is the !! (not not) operator in JavaScript?

Alshifa Hasnain
Updated on 20-Feb-2025 18:26:10

574 Views

In this article, we will learn about the !! (not not) operator in JavaScript.This double negation forces a value to be evaluated as either true or false. What is the !! Operator? The double negation(!! ) operator is the! Operator twice and calculates the truth value of a value. It returns a Boolean value, which depends on the truthiness of the expression.  How It Works: The first ! negates the value, converting it to true or false. The second ! negates it again, effectively converting it into a strict boolean (true or ... Read More

What is the difference between Bower and npm in JavaScript?

vanithasree
Updated on 12-Sep-2019 07:59:03

192 Views

  npmnpm is generally used for managing Node.js modules and does nested dependency tree. It also works for front-end and used for developer tools like Grunt, CoffeeScript, etc.Without using nested dependencies it is difficult to avoid dependency conflicts. So, using npm has proven to be great.Whatever you add in Node is structured as modules. On using NPM for browser-side dependencies, you'll structure your code like Node.Here’s the dependency structure:project root [node_modules] -> dependency P -> dependency Q [node_modules] -> dependency P -> dependency R [node_modules] -> dependency Q [node_modules] -> dependency P -> dependency SBower Bower requires a flat dependency tree and ... Read More

How to include JavaScript in HTML Documents?

Shubham Vora
Updated on 15-Sep-2022 12:15:18

1K+ Views

In this tutorial, we will learn how to include JavaScript in HTML Documents. To include JavaScript in HTML Documents, use the tag. JavaScript can be implemented using JavaScript statements that are placed within the ... . You can place the tags, containing your JavaScript, anywhere within your web page, but it is normally recommended that you should keep it within the tags. We will discuss the following three approaches to include JavaScript in HTML documents − Embedding code (within head or body) Inline Code (inside any element) External file (outside the HTML file) By Embedding ... Read More

Advertisements