Consider a simple stack class in Javascript. 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 empty isEmpty() { ... Read More
Here is the complete implementation of the Stack class −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 = []; } display() { console.log(this.container); } isEmpty() { return this.container.length === 0; } isFull() { return this.container.length >= this.maxSize; } ... Read More
You can assign a dictionary value to a variable in Python using the access operator []. For example,Examplemy_dict = { 'foo': 42, 'bar': 12.5 } new_var = my_dict['foo'] print(new_var)OutputThis will give the output −42This syntax can also be used to reassign the value associated with this key. For example,Examplemy_dict = { 'foo': 42, 'bar': 12.5 } my_dict['foo'] = "Hello" print(my_dict['foo'])OutputThis will give the output −Hello
HTML Editors are WYSIWYG editor program which gives options to edit source code. Some of the well-known editors include Adobe Dreamweaver, CoffeeCup, KomodoIDE, EditPlus, etc. To choose an HTML Editor, you need to compare some of the features and find the best one to edit the source code.While choosing and trying HTML Editors, try to get an IDE will some or all of the following features and capabilities −Code Collapsing When an enormous amount of code is written, then code collapsing features works great and to get an HTML Editor which provides this option will work like a charm and ... Read More
To use an image on a webpage, use the tag. The tag allows you to add image source, alt, width, height, etc. The alt is the alternate text attribute, which is text that is visible when the image fails to load.The following are the attributes −AttributeDescriptionAltThe alternate text for the imageHeightThe height of the imageIsmapThe image as a server-side image-mapLongdescThe URL to a detailed description of an imageSrcThe URL of an imageUsemapThe image as a client-side image-mapWidthThe width of the imageJust keep in mind the tag has no end tag.ExampleYou can try to run the following code to ... Read More
There are two ways to join 2 arrays in Javascript. If you want to get a new array and not want to disturb the existing arrays while joining the two arrays then you should use the concat method as follows − Examplelet arr1 = [1, 2, 3, 4]; let arr2 = [5, 6, 7, 8]; let arr3 = arr1.concat(arr2); console.log(arr1); console.log(arr2); console.log(arr3);OutputThis will give the output −[1, 2, 3, 4] [5, 6, 7, 8] [1, 2, 3, 4, 5, 6, 7, 8]Note that the existing arrays were not modified. If you want to join in place, you'll need to use the ... Read More
Javascript provides a collection of functions that you can use to find elements in an array. Let's start with the most basic one. The indexOf function goes through the entire array and returns the index of the element you searched for, if it is found else it returns -1. For example, Examplelet people = ["Harry", "Martha", "John", "Sam"]; console.log(people.indexOf("John")) console.log(people.indexOf("Jim"))OutputThis will give the output −2 -1There are other, more complex functions that you can use to make search more powerful. Let's look at find() method. The find() method returns the first object matching the condition you provide it as the ... Read More
Basically, multi-dimension arrays are used if you want to put arrays inside an array. Let's take an example. Say you wanted to store every 6 hour's temperature for every weekday. You could do something like −let monday = [35, 28, 29, 31]; let tuesday = [33, 24, 25, 29]; //...This is a good place to use a multidimensional array instead. A multidimensional array is nothing but an array of arrays. If we take forward our example, each row will represent a day while each entry in the row will represent a temp entry. For example, let temps = [ ... Read More
To bind jQuery events within dynamic content, use event delegation. You can try to run the following code to learn how to bind jQuery events within dynamic content returned via Ajax:Live Demo $(document).ready(function(){ $(".loadingAjax").on("click", function() { event.preventDefault(); var url = $(this).attr("href"), appendedContainer = $(".append"); $.ajax({ url: url, type : 'get', complete : function( qXHR, textStatus ) { if (textStatus === 'success') { var data = qXHR.responseText appendedContainer.hide(); appendedContainer.append("Hi"); appendedContainer.fadeIn(); } } }); }); $(document).on("click", '.link', function(event) { alert("Link clicked!"); }); }); a.test { font-weight: bold; } body { font-family: sans-serif;} Click to load Ajax
Assuming you have set up Python 3.6, Pipenv and heroku CLI installed locally and are logged in on Heroku from the CLI using the steps mentioned here: https://devcenter.heroku.com/articles/getting-started-with-python#set-up.Your application needs to have a git repository to be deployed to heroku. You need to cd in the directory where the root of your git repo code resides. Now you need to create a heroku application using:$ heroku create Creating lit-bastion-5032 in organization heroku... done, stack is cedar-14https://lit-bastion-5032.herokuapp.com/ | https://git.heroku.com/lit-bastion-5032.gitGit remote heroku addedWhen you create an app, a git remote (called heroku) is also created and associated with your local git repository. ... Read More
 Data Structure
 Networking
 RDBMS
 Operating System
 Java
 iOS
 HTML
 CSS
 Android
 Python
 C Programming
 C++
 C#
 MongoDB
 MySQL
 Javascript
 PHP