Ayush Gupta has Published 530 Articles

How to programmatically set the value of a select box element using JavaScript?

Ayush Gupta

Ayush Gupta

Updated on 27-Nov-2019 10:39:19

948 Views

We can set the value of a select box using Javascript using the following. Suppose we have the following select box −    Select    Apple    Strawberry    Cherry    Guava To set the value of this select element, we need to access it using querySelector. Then set the ... Read More

JavaScript Encapsulation using Anonymous Functions

Ayush Gupta

Ayush Gupta

Updated on 27-Nov-2019 10:37:08

405 Views

Object-oriented programming languages allow data hiding using private fields. They use these to hide the internals of classes. In JS there is no such in build support to hide/encapsulate the inner workings.We have Anonymous functions that can give you encapsulation in JS. Let us look at an example −Exampleconst HIDDEN_CONST ... Read More

The Pros and Cons of Using Ajax

Ayush Gupta

Ayush Gupta

Updated on 27-Nov-2019 10:35:33

6K+ Views

Ajax is a set of web development techniques using many web technologies on the client-side to create asynchronous web applications. With Ajax, web applications can send and retrieve data from a server asynchronously without interfering with the display and behavior of the existing page.Any other technology Ajax also has its ... Read More

Safely setting object properties with dot notation strings in JavaScript

Ayush Gupta

Ayush Gupta

Updated on 27-Nov-2019 10:34:36

923 Views

You can use lodash's set method to set properties at any level safely. Setting first-level properties are pretty straightforward. Nested property access is tricky and you should use a tested library like lodash for it.You can set a deeply nested object in the following way −Examplelet _ = require("lodash"); let ... Read More

Safely Accessing Deeply Nested Values In JavaScript

Ayush Gupta

Ayush Gupta

Updated on 27-Nov-2019 10:27:51

390 Views

You can use lodash's get method to get properties at any level safely. Getting first-level properties is pretty straightforward. Nested property access is tricky and you should use a tested library like lodash for it.You can access a deeply nested object in the following way −Examplelet _ = require("lodash"); let ... Read More

Accessing nested JavaScript objects with string key

Ayush Gupta

Ayush Gupta

Updated on 27-Nov-2019 10:23:09

2K+ Views

You can use lodash's get method to get properties at any level safely. Getting first-level properties is pretty straightforward. Nested property access is tricky and you should use a tested library like lodash for it.You can access a deeply nested object in the following way −Examplelet _ = require("lodash"); let ... Read More

How to Send and Receive JSON Data to and from the Server

Ayush Gupta

Ayush Gupta

Updated on 27-Nov-2019 10:20:22

3K+ Views

JavaScript can send network requests to the server and load JSON. JS does this using something called AJAX. AJAX stands for Asynchronous JavaScript and XML. JS has an API, fetch, to GET(receive) and POST(send) information to the server.You can use fetch to GET JSON data in the following way −Exampleconst ... Read More

Query-string encoding of a Javascript Object

Ayush Gupta

Ayush Gupta

Updated on 27-Nov-2019 10:16:51

196 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. It 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) ... Read More

What are the differences between lodash and underscore?

Ayush Gupta

Ayush Gupta

Updated on 27-Nov-2019 10:03:22

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, & stringsManipulating & testing valuesCreating composite functionsThey are both functional libraries. Lo-Dash is a fork of Underscore, ... Read More

Difference between Backbone.js and Jquery

Ayush Gupta

Ayush Gupta

Updated on 27-Nov-2019 10:00:04

281 Views

Backbone is an MV* framework while jQuery is a DOM toolkit.With Backbone, you represent data as Models, which can be created, validated, destroyed, and saved to the server. Whenever a UI action causes an attribute of a model to change, the model triggers a "change" event; all the Views that ... Read More

Advertisements