Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles on Trending Technologies
Technical articles with clear explanations and examples
Searching for values in an Javascript Binary Search Tree
We're going to use the property of a BST to look up elements in it. In a Binary Search Tree, values smaller than the current node are in the left subtree, and values larger are in the right subtree, making search operations efficient. Iterative Search Implementation The iterative approach uses a loop to traverse the tree: searchIter(data) { let currNode = this.root; while (currNode !== null) { if (currNode.data === data) { ...
Read MoreWhat is importance of startsWith() method in JavaScript?
To check whether a string starts with a particular character or substring, the indexOf() method was traditionally used. However, ES6 introduced the more intuitive and readable startsWith() method, which is specifically designed for this purpose and offers better performance and clarity. Traditional Approach: Using indexOf() The indexOf() method returns the first index where a substring is found. To check if a string starts with specific characters, we compare the result with 0: var text = 'Tutorialspoint'; document.write(text.indexOf('T') === 0); true ...
Read MoreHow to create a length converter with HTML and JavaScript?
To create a length converter with HTML and JavaScript, you'll need to combine HTML form elements with JavaScript functions to handle the conversion logic. This tutorial demonstrates building a simple kilometer-to-meter converter. HTML Structure The converter uses an input field for kilometers and displays the converted meters value. The oninput and onchange events trigger the conversion function automatically as you type. Complete Example body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; padding: 20px; ...
Read MoreJavaScript program to retrieve clients IP address
Internet Protocol address, in short, IP address, is a unique address represented by a string of numbers that identifies a device on the internet or a local network. In JavaScript, we can retrieve a client's IP addresses using 3rd party API services such as ipify or ipapi. We can then further use this information to track user locations, personalize content based on the location, or implement security measures. Understanding Client-Side IP Detection JavaScript running in the browser cannot directly access the client's IP address due to security restrictions. However, we can use external APIs that return the public ...
Read MoreRemove any text not inside element tag on a web page with JavaScript?
To remove text nodes that are not inside HTML element tags, we use jQuery's contents() and filter() methods to identify text nodes, then remove() to delete them. Understanding Text Nodes vs Element Nodes In the DOM, there are different node types: Element nodes (nodeType = 1): HTML tags like , Text nodes (nodeType = 3): Plain text content not wrapped in tags Example HTML Structure Consider this HTML where we want to remove the unwrapped text: Demo Program This is also Demo Program The text "This is also Demo ...
Read MoreHow do I trigger a function when the time reaches a specific time in JavaScript?
To trigger a function at a specific time in JavaScript, calculate the time difference between the current time and target time, then use setTimeout() with that delay. Basic Approach Extract the target time, calculate the milliseconds until that time, and schedule the function execution: Trigger Function at Specific Time Function will trigger at specified time Waiting for target time... ...
Read MoreSplitting string into groups – JavaScript
Given a string S, consisting of alphabets, numbers and special characters. We need to write a program to split the strings in three different strings S1, S2 and S3, such that − The string S1 will contain all the alphabets present in S, The string S2 will contain all the numbers present in S, and S3 will contain all special characters present in S. The strings S1, S2 and S3 should have characters in the same order as they appear in input. Syntax const ...
Read MoreWhat to do with content that renders outside the element box with JavaScript?
When content exceeds an element's dimensions, it can overflow outside the visible area. JavaScript provides several ways to handle this using the overflow property, which controls how overflowing content is displayed. Understanding Overflow Values The overflow property accepts several values: visible - Default behavior, content flows outside the box hidden - Clips content that overflows scroll - Always shows scrollbars auto - Shows scrollbars only when needed Example: Dynamic Overflow Control Here's a complete example demonstrating how to manage overflow with JavaScript: ...
Read MoreHow to make an Ember.js app offline with server sync when available?
Making an Ember.js app work offline with server synchronization requires implementing client-side storage that can sync data when connectivity is restored. This enables users to continue working with your app even without internet access. Using LocalStorage Adapter The ember-localstorage adapter provides basic offline storage capabilities by storing data in the browser's localStorage: App.store = DS.Store.create({ revision: 11, adapter: DS.LSAdapter.create() }); Advanced Offline Storage with IndexedDB For more robust offline functionality, use IndexedDB which provides better performance and storage capacity: App.Store = DS.SyncStore.extend({ ...
Read MoreHTML5 getCurrentPosition almost always failing in PhoneGap on iOS
When using HTML5 geolocation in PhoneGap applications on iOS devices, getCurrentPosition may fail frequently, especially on iOS 6. This issue affects location-based functionality and requires specific configuration changes to resolve. The Problem PhoneGap's geolocation API generally works well on iOS, but iOS 6 introduced specific issues where getCurrentPosition consistently triggers the failure callback instead of successfully retrieving the device's location. PhoneGap Configuration Fix The primary solution involves modifying the PhoneGap.plist file configuration: // In PhoneGap.plist, set the geolocation setting to: GeolocationEnabled: NO Setting this value to YES causes memory problems on iOS ...
Read More