Object Oriented Programming Articles

Page 89 of 589

How to allocate memory in Javascript?

Ayush Gupta
Ayush Gupta
Updated on 15-Mar-2026 610 Views

Regardless of the programming language, memory life cycle is pretty much always the same: Allocate the memory you need Use the allocated memory (read, write) Release the allocated memory when it is not needed anymore The second part is explicit in all languages. Use of allocated memory needs to be done by the developer. The first and last parts are explicit in low-level languages like C but are mostly implicit in high-level languages like JavaScript. Hence there is no explicit way to allocate or free up memory in JavaScript. Just initializing objects allocates memory ...

Read More

Advanced JavaScript Backend Basics

sudhir sharma
sudhir sharma
Updated on 15-Mar-2026 840 Views

JavaScript is a lightweight, interpreted programming language primarily used for web development. Each browser has its own JavaScript engine that enables proper code execution. Common browsers and their JavaScript engines include: SpiderMonkey for Firefox V8 for Google Chrome JavaScriptCore for Safari Chakra for Microsoft Internet Explorer/Edge To standardize JavaScript across browsers, the ECMA (European Computer Manufacturers Association) sets official standards for the language. How JavaScript Engine Works JavaScript engines execute code in two distinct phases to ensure proper functionality across all browsers: ...

Read More

What is the difference between `new Object()` and object literal notation in JavaScript?

Ayush Gupta
Ayush Gupta
Updated on 15-Mar-2026 706 Views

JavaScript provides two main ways to create objects: new Object() constructor and object literal notation {}. While both create objects, they have important differences in syntax, performance, and flexibility. Object Literal Notation Object literal notation uses curly braces {} to create objects directly with properties: let person = { name: 'Ayush', age: 25, city: 'Delhi' }; console.log(person.name); console.log(person); Ayush { name: 'Ayush', age: 25, city: 'Delhi' } Using new Object() Constructor The new Object() constructor creates an ...

Read More

What is JSlint error "missing radix parameter" in JavaScript?

Ayush Gupta
Ayush Gupta
Updated on 15-Mar-2026 1K+ Views

The parseInt function in JavaScript has the following signature: parseInt(string, radix); Where the parameters are: 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. The Problem: Omitting the Radix Parameter If the radix parameter is omitted, JavaScript assumes the following: If the string begins ...

Read More

Query-string encoding of a Javascript Object

Ayush Gupta
Ayush Gupta
Updated on 15-Mar-2026 257 Views

The query string is made up of query parameters and used to send data to the server. This part of the URL is optional and needs to be constructed by the developer. This can be done using a native method called encodeURIComponent(). The encodeURIComponent() function encodes a Uniform Resource Identifier (URI) component by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character. Using Object.keys() and map() Using ES6 features, objects can be query string encoded by combining Object.keys(), map(), and join() methods: let ...

Read More

Write the dependencies of backbone.js in javascript?

Ayush Gupta
Ayush Gupta
Updated on 15-Mar-2026 282 Views

Backbone.js is a lightweight JavaScript framework that requires specific dependencies to function properly. Understanding these dependencies is crucial for setting up and working with Backbone.js applications. Hard Dependency The only hard dependency (without which Backbone.js won't work at all) is Underscore.js. Underscore is a JavaScript library that provides a whole mess of useful functional programming helpers without extending any built-in objects. // Including Underscore.js is mandatory Optional Dependencies There are other dependencies required as you proceed to use more advanced features of Backbone.js: jQuery or ...

Read More

What are the differences between lodash and underscore?

Ayush Gupta
Ayush Gupta
Updated on 15-Mar-2026 1K+ Views

Lodash and Underscore are both utility libraries that make JavaScript easier by providing utils that make working with arrays, numbers, objects, strings, etc. much easier. These libraries are great for: Iterating arrays, objects, & strings Manipulating & testing values Creating composite functions They are both functional libraries. Lodash is a fork of Underscore, and still follows Underscore's API enough to allow it to serve as a drop-in replacement. But under the hood, it's been completely rewritten, and it's also added a number of features and functions that ...

Read More

Increment a date in javascript without using any libraries?

Ayush Gupta
Ayush Gupta
Updated on 15-Mar-2026 229 Views

To increment a date in JavaScript without external libraries, use the setDate() method. This approach automatically handles month and year rollovers. Using setDate() Method The setDate() method accepts day values beyond the current month's range. JavaScript automatically adjusts the month and year when necessary. let date = new Date('2024-01-31'); // January 31st date.setDate(date.getDate() + 1); // Add 1 day console.log(date.toDateString()); Thu Feb 01 2024 Creating a Reusable Function You can extend the Date prototype or create a standalone function to add days: Date.prototype.addDays = function(days) { ...

Read More

Safely Accessing Deeply Nested Values In JavaScript

Ayush Gupta
Ayush Gupta
Updated on 15-Mar-2026 489 Views

Accessing deeply nested properties in JavaScript can cause errors if intermediate properties don't exist. Modern JavaScript provides several safe approaches to handle this common problem. The Problem with Direct Access Directly accessing nested properties throws errors when intermediate properties are undefined: let obj = { user: { profile: { name: "John" } } }; console.log(obj.user.profile.name); // "John" - ...

Read More

How to create an object property from a variable value in JavaScript?

Ayush Gupta
Ayush Gupta
Updated on 15-Mar-2026 9K+ Views

JavaScript has two notations for creating object properties: dot notation and bracket notation. To create an object property from a variable value, you need to use bracket notation or ES6 computed property names. Method 1: Using Bracket Notation (Dynamic Assignment) You can assign properties to existing objects using bracket notation with variable names: const obj = {a: 'foo'}; const prop = 'bar'; // Set the property using the variable name prop obj[prop] = 'baz'; console.log(obj); { a: 'foo', bar: 'baz' } Method 2: Using ES6 Computed Property Names ES6 ...

Read More
Showing 881–890 of 5,881 articles
« Prev 1 87 88 89 90 91 589 Next »
Advertisements