Creating a Priority Queue using JavaScript

karthikeya Boyini
Updated on 15-Jun-2020 08:54:25

553 Views

Our class will have the following functions −enqueue(element): Function to add an element in the queue.dequeue(): Function that removes an element from the queue.peek(): Returns the element from the front of the queue.isFull(): Checks if we reached the element limit on the queue.isEmpty(): checks if the queue is empty.clear(): Remove all elements.display(): display all contents of the arrayLet's start by defining a simple class with a constructor that takes the max size of the queue and a helper function that'll help us when we implement the other functions for this class. We'll also have to define another structure as part ... Read More

Add Elements to a PriorityQueue Using JavaScript

Samual Sam
Updated on 15-Jun-2020 08:53:23

253 Views

Enqueuing elements to a PriorityQueue means adding them in the array in order of the priority of the element. We'll consider higher numbers to be higher priorities. We'll loop through the container till we find a lower priority and then add the element there. If not, then we'll push it at the end of the container.Note that we're creating the element object with the data and priority. Hence we can implement the enqueue function as follows −  Exampleenqueue(data, priority) {    // Check if Queue is full    if (this.isFull()) {       console.log("Queue Overflow!");       return; ... Read More

Use POST Method to Send Data in jQuery Ajax

Amit D
Updated on 15-Jun-2020 08:52:44

4K+ Views

The jQuery.post( url, [data], [callback], [type] ) method loads a page from the server using a POST HTTP request.Here is the description of all the parameters used by this method −url − A string containing the URL to which the request is sentdata − This optional parameter represents key/value pairs or the return value of the .serialize() function that will be sent to the server.callback − This optional parameter represents a function to be executed whenever the data is loaded successfully.type − This optional parameter represents a type of data to be returned to callback function: "xml", "html", "script", "json", "jsonp", or "text".Let’s say ... Read More

Delete Bookmarks in Your Browser: Firefox & Chrome

Rahul Sharma
Updated on 15-Jun-2020 08:51:40

308 Views

Bookmarks in a web browser are saved so that it can be referred. It is also known as favorite web pages. To Bookmark a web page, visit the page and press Ctrl+D. This will give you an option to save the web page.In this way, all the bookmarks get saved like this on pressing Ctrl+D. The star sign as you can see below also allows you to add a bookmark −Bookmark on FirefoxBookmark on ChromeLet’s learn how to delete a bookmark in a web browser. To delete a bookmark, which you bookmarked before in Firefox or Chrome, you need to ... Read More

Difference between SBObob GetItemPrice and CompanyService GetItemPrice in SAP B1

Giri Raju
Updated on 15-Jun-2020 08:51:16

289 Views

As per my understanding, SBObob takes fewer parameters but provide the more accurate result for item price taking into accounts for BP and quantity of items, etc. CompanyService GetItemPrice accepts more parameters however information is scarce in the SDK help file for this method. Also, note that there is no information on this return type.ItemPriceReturnParams uses below properties:CurrencyDiscountPrice

The do...while Loop in JavaScript

Samual Sam
Updated on 15-Jun-2020 08:50:59

397 Views

The do...while loop is similar to the while loop except that the condition check happens at the end of the loop. This means that the loop will always be executed at least once, even if the condition is false.For example,Examplelet i = 0; do {    console.log("Hello");    i = i + 1; } while (i < 5);This will give the output −OutputHello Hello Hello Hello Hello

jQuery ajaxSetup Method

Amit D
Updated on 15-Jun-2020 08:50:16

372 Views

The jQuery.ajaxSetup() method sets global settings for future AJAX requests. Here is the description of all the parameters used by this method-Let’s say we have the following HTML content in result.html file,THIS IS RESULT...The following is an example showing the usage of this method. Here we make use of success handler to populate returned HTML:           The jQuery Example                              $(document).ready(function() {                         $("#driver").click(function(event){                // Do global setting.                $.ajaxSetup({                   url: "result.html"                });                                    $.ajax( {                   success:function(data) {                      $('#stage').html(data);                   }                });             });          });                             Click on the button to load result.html file:                        STAGE                                 Live Demo

Change Firefox Browser Theme

Johar Ali
Updated on 15-Jun-2020 08:44:18

405 Views

Firefox web browser is widely used and loved by many users around the world. Well, you can easily change the Firefox Browser theme and make it look more awesome.Let’s see how to reach the Firefox theme section and change the theme −Open Firefox MenuGo to the following section and click to open the Firefox browser menu. After that, you need to click Add-ons:AppearanceTo reach the Themes section, click on Add-ons and then click on Appearance as shown below −On clicking Appearance, the themes will be visible. Click Enable to enable any theme or choose from thousands of other themes as ... Read More

Design a Modern Website

Ali
Ali
Updated on 15-Jun-2020 08:43:09

238 Views

Modern websites are responsive and the design works fine on multiple devices such as Desktop, Tablet, and Mobile. Also, websites these days do not follow the old font styles, many of them use Google fonts since it’s easy to find a font-face matching your website's content and Google provides a lot of free fonts to choose from.Modern websites display beautifully formatted content on multiple devices such phones, tablets, and desktops. Also, nowadays Retina-ready logo helps in keeping your logo amazing, no matter the resolution.Follow the below given steps and learn how to design a modern website −Design StylesFor design style, ... Read More

Pushing Elements to a Stack in JavaScript

Samual Sam
Updated on 15-Jun-2020 08:40:11

294 Views

Consider the following stack class in Javascript with few small helper functions.Exampleclass Stack {    constructor(maxSize) {       // Set default max size if not provided       if (isNaN(maxSize)) {          maxSize = 10;       }       this.maxSize = maxSize; // Init an array that'll contain the stack values.       this.container = [];    }    // A method just to see the contents while we develop this class    display() {       console.log(this.container);    }    // Checking if the array is ... Read More

Advertisements