Found 6710 Articles for Javascript

Name some methods of weakMap instances in javascript?

Abdul Rawoof
Updated on 26-Aug-2022 11:58:00

127 Views

WeakMap is a collection in JavaScript. This type of collection is used to store the data in the form of key-value pairs. In WeakMap, the key must be definitely an object and the values can be of any type. New function in weakMaps A new WeakMap is created using the ‘new’ key word dynamically. Syntax A new WeakMap is created using the syntax mentioned below. var weakMapName = new WeakMap() Example 1 This example demonstrates how to create a WeakMap using new operator in JavaScript − var wkMap = new WeakMap() if(wkMap){ console.log("WeakMap is created using ... Read More

Why do we need weakMaps in Javascript?

Abdul Rawoof
Updated on 26-Aug-2022 11:57:42

447 Views

WeakMap is a collection in JavaScript. This type of collection is used to store the data in the form of key-value pairs. In WeakMap, the key must definitely be an object and the values can be of any type. The difference between a Map and a WeakMap is, in weakmap key must be an object and the other difference is that a weakmap is like a blackbox where the keys can’t be retrieved. The value of the weakmap can be accessed only if the key is known which means the values in the weakmap are private. Additional data can be ... Read More

Differences between web-garden and a web-farm in Javascript

Ayush Gupta
Updated on 16-Sep-2019 08:52:25

418 Views

Web Garden is the web hosting system which comprises of multiple “processes”. This means that we have a single server on which we run multiple processes. This type of hosting provides logical scalability to our web applications.Web Farm is the web hosting system which comprises of multiple “computers”. This is different from web-garden as web garden runs on a single server while a web farm runs across multiple servers. This provides physical scalability to out web applications. This type of set up is achieved using Load balancers to balance calls coming to the server using a dedicated process that forwards ... Read More

Window.onload vs onDocumentReady in javascript

Abdul Rawoof
Updated on 02-Sep-2022 12:37:51

6K+ Views

In JavaScript, window.onload and document.ready() are the methods used when the page is being loaded. Window.onload The window.onload method gets executed after the entire web page is loaded. This includes all the elements related with DOM like the head tag, tittle tag and all the other tags including the style sheets, images and videos. The onload method is used by passing a function to it. The called function will be executed after the object is loaded. Syntax This is the syntax of onload method − Window.onload = function() Window.onload = (event) => {} //arrow function Example 1 This example ... Read More

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

How to find operating system in the client machine using JavaScript?

Abdul Rawoof
Updated on 26-Aug-2022 11:58:35

1K+ Views

The type of operating system used in the client machine can be detected using some of the functions in JavaScript. The different functions are discussed below. Using navigator.appVersion This property will return the information about the browser and the operating system being used in the form of a string. Syntax The syntax for the navigator.appVersion is given below. navigator.appVersion Example 1 This example demonstrates the usage of navigator.appVersion to detect client OS − Click to get the operating system Operating System ... Read More

Disadvantages of using innerHTML in JavaScript

Abdul Rawoof
Updated on 26-Aug-2022 12:00:15

3K+ Views

HTML stands for Hyper Text Markup Language, through the HTML we can design a block of webpages. Html is a frontend markup language that is used to build the content of frontend pages. It means that we can build a structure of web pages. Through HTML we can design the content of any website. It means that we can create headings, buttons, paragraphs, headers, footers, links, etc for any website. Example let’s try to understand to implement a program − Basic of ... Read More

Convert the string of any base to integer in JavaScript

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

155 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

How to read and write a file using JavaScript?

Abdul Rawoof
Updated on 13-Nov-2024 16:05:23

82K+ Views

The read and write operations on a file can be done by using specific commands. The module required to perform these operations must be imported first. The required module is 'fs', which is called the File System module in Node.js Write Operation on a File After the File System file is imported then, the writeFile() operation is called. The writeFile() method is used to write into the file in JavaScript. Syntax writeFile(path, inputData, callBackFunc) Parameters The writeFile() function accepts three parameters as mentioned below. Path: The first parameter is the path of ... Read More

Advertisements