Front End Technology Articles - Page 511 of 860

How to enable a strict mode in javascript?

Arnab Chakraborty
Updated on 04-Apr-2023 11:37:42

168 Views

In JavaScript, there are two different programming paradigms. The sloppy mode, sometimes referred to as the simple mode, is activated by default. We don't have to write the code strictly according to guidelines in this manner. On the other side, there is also the stringent mode. This setting allows the environment to have some rigid constraints. Strict mode has different meanings than regular code and is not a subset of sloppy mode. This article will explain how to enable strict mode in JavaScript and will also go over some of the features of "Strict" Mode. Syntax Different scopes can allow ... Read More

What are the characteristics of JavaScript 'Strict Mode'?

Arnab Chakraborty
Updated on 22-Aug-2022 12:32:00

446 Views

This tutorial will explain you what are the different characteristics of JavaScript 'Strict Mode'. As such, there are two different modes of programming in JavaScript. By default, the simple mode or sometimes known as the sloppy mode is enabled. In this mode, we do not need to follow strict rules while writing the code. On the other hand, the strict mode is also there. This mode enables some strict rules in the environment. Strict mode is not a subset of the sloppy mode but it also has different semantics than normal code. Syntax Strict modes can be ... Read More

Convert the string of any base to integer in JavaScript

Ayush Gupta
Updated on 16-Sep-2019 08:19:08

162 Views

The parseInt function available in JavaScript has the following signature −parseInt(string, radix);Where, the paramters are the following −String − The value to parse. If this argument is not a string, then it is converted to one using the ToString method. Leading whitespace in this argument is ignored.Radix − An integer between 2 and 36 that represents the radix (the base in mathematical numeral systems) of the string.So we can pass the string and the radix and convert any numbner with base from 2 to 36 to integer using this method.Exampleconsole.log(parseInt("100", 10)) console.log(parseInt("10", 8)) console.log(parseInt("101", 2)) console.log(parseInt("2FF3", 16)) console.log(parseInt("ZZ", 36))Output100 8 ... Read More

Difference between test () and exec () methods in Javascript

Abdul Rawoof
Updated on 02-Sep-2022 11:55:12

7K+ Views

The RegExp.prototype.test() and RegExp.prototype.exec() methods are the methods in JavaScript used to handle regular expressions. In addition to these two JavaScript includes a number of built-in methods for manipulating and processing text using regular expressions. What are regular expressions? Regular expressions are patterns that are used to search for character combinations in a string. Regular expressions are treated as objects in JavaScript and are denoted by either "regex" or "RegExp." The exec() method The exec() method makes a search for the specified match of the string in the given string. If the match of the string is present in the ... Read More

What is "undefined x 1" in JavaScript?

Ayush Gupta
Updated on 16-Sep-2019 08:03:51

184 Views

This is not a feature of JavaScript but is Chrome's way of displaying uninitialized indexes in arrays (and array-like objects). For example, if you console.log the following −Exampleconsole.log(Array(100))Output[undefined × 100]This is better than printing [undefined, undefined, undefined,...] as it is more readable.

In Javascript how to empty an array

Ayush Gupta
Updated on 07-Oct-2023 03:16:27

24K+ Views

There are multiple ways to clear/empty an array in JavaScript. You need to use them based on the context. Let us look at each of them. Assume we have an array defined as − let arr = [1, 'test', {}, 123.43]; Substituting with a new array − arr = []; This is the fastest way. This will set arr to a new array. This is perfect if you don't have any references from other places to the original arr. If you do, those references won't be updated and those places will continue to use the old array. Setting length prop ... Read More

What is the drawback of creating true private methods in JavaScript?

Manisha Patil
Updated on 24-Aug-2022 07:09:29

415 Views

Using private methods has a simple underlying concept. In this situation, you can declare private methods or private properties, which are used to hide a class's internal functionality from those other classes, whenever you wish to keep something private, whether it be a method or a property. You can include private fields, static methods, instance methods, and getters and setters that are only accessible to you. Truly private fields and methods are delivered through private class features, with the language maintaining that privacy rather than a custom. Benefits include preventing naming conflicts between class features and the other of the ... Read More

How do you test if a value is equal to NaN in Javascript?

Lokesh Yadav
Updated on 08-Dec-2022 07:44:25

364 Views

This article discusses about how do you test if a value is equal to NaN in JavaScript. In JavaScript, NaN is a method from Number class. NaN implies Not-a-Number. It is of Boolean type. It returns true when the value is “Not-a-number”. The NaN method is used in the situations. For example, when a function tries to parse a number and it fails or when a math function fails, the method NaN is used. The syntax for isNaN() method is shown below. isNaN(); or Number.isNaN(); There is a difference between isNaN() and Number.isNaN(). If the value is currently NaN ... Read More

Which one is faster between JavaScript and an ASP script?

Lokesh Yadav
Updated on 08-Dec-2022 07:42:27

1K+ Views

In this article, we are going to discuss about the quickest language between JavaScript and ASP script. JavaScript is a light weighted and compiled language. It is a popular client-side scripting language. The content of JavaScript code is visible to the users. The extension for a JavaScript file is .js. Active Server Pages Script is popularly known as ASP script. It is a server-side scripting language to develop dynamic web pages. The extension for an ASP script file is .asp. Consider a Three-tier architecture – Presentation layer, Application layer and Data layer. JavaScript is used in the presentation layer. JavaScript ... Read More

Why is javascript called Richer Interface?

Ayush Gupta
Updated on 16-Sep-2019 07:40:36

212 Views

JavaScript allows you to add very advanced features to your web applications. For example, Drawing and manipulating graphicsAudio and Video APIs like HTMLMediaElement, the Web Audio API, and WebRTC allow you to do really interesting things with multimedia such as creating custom UI controls for playing audio and video, displaying text tracks like captions and subtitles along with your videos, grabbing video from your web camera to be manipulated via a canvas (see above) or displayed on someone else's computer in a web conference, or adding effects to audio tracks (such as gain, distortion, panning, etc).Device APIs are basically APIs ... Read More

Advertisements