Found 9321 Articles for Object Oriented Programming

Why does the JavaScript need to start with “;”?

Ramu Prasad
Updated on 23-Jun-2020 11:51:06

91 Views

JavaScript uses a semi-colon (;) to avoid any confusion in code, especially the beginning of a new line.ExampleYou can still use the following to avoid any chaos in the code −return {    'var':myVal } // using semi-colon; (function( $ ) {    // }

How and why does 'z'['toUpperCase']() in JavaScript work?

Shubham Vora
Updated on 22-Aug-2022 09:04:13

167 Views

In this tutorial, we will learn how and why ‘z’[‘toUpperCase’]() works in JavaScript. From the given format, we can say that it calls the toUpperCase() method for the ‘z’ string. It will work the same as the toUpperCase() method, which we invoke by taking any string as a reference. Let’s understand the syntax of the ‘z’[‘toUpperCase’]() below. Syntax let result = 'z'['toUpperCase'](); // returns 'Z', string in upper case The above syntax is same as the below. Example let string = 'z'; let result = string.toUpperCase(); Why does ‘z’[‘toUpperCase’]() work? In JavaScript toUpperCase() method is used to convert ... Read More

How to create JavaScript data grid for millions of rows?

Nancy Den
Updated on 23-Jun-2020 11:51:58

208 Views

To display million of rows of data to the users in a grid, use any of the following grids −S. NoGridDescription1DataTablesAllows adding advanced interaction controls to any HTML table.2IngridAllows resizing columns, paging, sorting, row and column styling to tables.3SlickGridUses virtual rendering to allow you to work with hundreds of thousands of items.Let us see the features of SlickGrid −Easily customizableComplete keyboard navigationEasily handles hundreds of thousands of rowsQuick rendering speedColumn autosizing availablePluggable cell formatters availableAllos creating new rows

Is their a JavaScript Equivalent to PHP explode()?

Ankith Reddy
Updated on 23-Jan-2020 07:05:08

2K+ Views

The JavaScript equivalent to PHP explode() is split(). To get the data after the first colon, try to run the following code.Example                    var str = '087000764008:Rank:info:result';          var arr = str.split(":");          document.write(arr[1] + ":" + arr[2]);          

How to hide HTML element with JavaScript?

Shubham Vora
Updated on 10-Sep-2023 07:49:14

44K+ Views

In this tutorial, we will learn how to hide HTML element with JavaScript. Hiding an HTML element can be performed in different ways in JavaScript. In this tutorial, we will see the three most popular ways of doing it − Using the hidden property Using the style.display property Using the style.visibility property Generally, we use the hidden attribute to hide a particular element. We can toggle between hiding and showing the element by setting the hidden attribute value to true or false, respectively. In the other two ways, we use the style object of the element. We ... Read More

How to display HTML element with JavaScript?

Shubham Vora
Updated on 31-Oct-2022 07:18:48

5K+ Views

In this tutorial, we will learn how to display an HTML element using JavaScript. HTML elements are the components that make up an HTML format file. These components are in charge of constructing web pages and defining their content. In HTML, an element typically consists of a start tag (tag name), a closing tag (tag name), and any text that is added in between. A collection of end tags, start tags, content, and attributes is what constitutes an element technically. Some HTML elements are − Starting Tag Content Ending Tag This is a paragraph. ... Read More

How to define global variable in a JavaScript function?

Sravani S
Updated on 23-Jun-2020 11:56:54

321 Views

To declare a global variable, use the var at global scope −    var myGlobalVariable;    function display() {       //    } For JavaScript function, assign the property to a window −    function display() {       window. myGlobalVariable = …;    }

How to replace all dots in a string using JavaScript?

Prabhdeep Singh
Updated on 07-Nov-2022 06:11:14

4K+ Views

In this tutorial, we will explore the different ways by which we can replace all dots in a string using JavaScript. It is possible to remove all occurrences of dots in a string manually by running a for loop, but JavaScript provides many functions by which we can accomplish the same task very easily. This is precisely what we will discuss in this article. The two most popular methods by which we can replace all dots in a string using JavaScript are − Using the replaceAll() method in JavaScript JavaScript strings have a method called replaceAll(), to which we can ... Read More

How to print content of JavaScript object?

Shubham Vora
Updated on 15-Sep-2022 12:31:06

4K+ Views

In this tutorial, we will learn to print the content of a JavaScript object. Objects are similar to variables, but they can contain many values. Javascript object values are written as key: value pairs, and each pair is separated by commas. It is used to access data from databases or any other sources. Following are the ways to print the content of JavaScript objects − Using the JSON.stringify() Method And using a for-in loop Using Object.values() Using the JSON.stringify() Method The JSON.stringify() is used to convert JavaScript Objects into a string. We have to use JSON.stringify() to send ... Read More

How to allow long and unbreakable words to be broken and wrap to the next line in JavaScript?

V Jyothi
Updated on 23-Jun-2020 11:44:49

288 Views

Use the wordWrap property in JavaScript to allow long words to be broken and wrap to the next line.ExampleYou can try to run the following to learn how to work with wordWrap property −                    #box {             width: 150px;             height: 150px;             background-color: lightblue;             border: 1px solid black;          }                     Set                ThisisDemoText.ThisisDemoText.ThisisDemoText.ThisisDemoText.Thisis DemoText.ThisisDemoText.                      function display() {             document.getElementById("box").style.wordWrap = "break-word";          }          

Advertisements