Ayush Gupta

Ayush Gupta

433 Articles Published

Articles by Ayush Gupta

Page 36 of 44

C++ program to generate random alphabets

Ayush Gupta
Ayush Gupta
Updated on 03-Dec-2019 949 Views

In this tutorial, we will be discussing a program to generate random alphabets.For this, we will have a fixed size of array/string and use the rand() function to generate a random string of alphabets.Example#include using namespace std; const int MAX = 26; //generating a string of random alphabets string gen_random(int n){    char alphabet[MAX] = {       'a', 'b', 'c', 'd', 'e', 'f', 'g',       'h', 'i', 'j', 'k', 'l', 'm', 'n',       'o', 'p', 'q', 'r', 's', 't', 'u',       'v', 'w', 'x', 'y', 'z'    };    string res ...

Read More

C++ program to generate CAPTCHA and verify user

Ayush Gupta
Ayush Gupta
Updated on 03-Dec-2019 877 Views

In this tutorial, we will be discussing a program to generate CAPTCHA and verify user.For this, we will provide the user with a random string and ask him to reenter the same string. Then it has to be checked if the given and the input string matches.The CAPTCHA should be completely random system generated consisting of a-z, AZ and 0-9.Example#include using namespace std; //checks if the strings are same bool check_string(string &captcha, string &user_captcha){    return captcha.compare(user_captcha) == 0; } //generates a random string as Captcha string gen_captcha(int n){    time_t t;    srand((unsigned)time(&t));    char *chrs = "abcdefghijklmnopqrstuvwxyzABCDEFGHI" "JKLMNOPQRSTUVWXYZ0123456789"; ...

Read More

Jasmine.js comparing arrays

Ayush Gupta
Ayush Gupta
Updated on 02-Dec-2019 1K+ Views

Arrays can be compared in 2 ways −They refer to the same array object in memory.They may refer to different objects but their contents are all equal.For case 1, jasmine provides the toBe method. This checks for reference. For example, Exampledescribe("Array Equality", () => {    it("should check for array reference equility", () => {       let arr = [1, 2, 3];       let arr2 = arr       // Runs successfully       expect(arr).toBe(arr2);       // Fails as references are not equal       expect(arr).toBe([1, 2, 3]);    }); });OutputThis ...

Read More

What is the use of sentry in javascript?

Ayush Gupta
Ayush Gupta
Updated on 02-Dec-2019 395 Views

Sentry is a complete javascript debugging and monitoring tool package that allows you to track your production code. Some of the features of sentry −Record environment and usage details to recreate and fix bugsSee the error and stack trace previously only visible in user's debug console.Apply source maps automatically to convert minified, compiled, or transpiled code back to its original form.Mobile app reporting support.

Read More

Difference between application/x-javascript and text/javascript content types?

Ayush Gupta
Ayush Gupta
Updated on 02-Dec-2019 1K+ Views

The text/javascript content type is obsolete. This was used in the early days of Html.application/x-javascript was an experimental content type(hence the x-). You should not be using this in your application.The correct content type to use in browsers is application/javascript. This helps browsers accept the content as js code.

Read More

What is the replacement of lodash pluck() method?

Ayush Gupta
Ayush Gupta
Updated on 02-Dec-2019 2K+ Views

Pluck has been removed from lodash 4. This is because it did the same thing as a map.As a replacement, you can use the map function in the following way −Exampleimport _ from 'lodash' const objects = [{ 'a': 1 }, { 'a': 2 }]; console.log(_.map(objects, 'a'))OutputThis will give the output −[1, 2]

Read More

Where is _.pluck() in lodash version 4?

Ayush Gupta
Ayush Gupta
Updated on 02-Dec-2019 466 Views

Pluck has been removed from lodash 4. This is because it did the same thing as a map.As a replacement, you can use the map function in the following way −Exampleimport _ from 'lodash' const objects = [{ 'a': 1 }, { 'a': 2 }]; console.log(_.map(objects, 'a'))This will give the output −Output[1, 2]

Read More

Why doesn't JavaScript support multithreading?

Ayush Gupta
Ayush Gupta
Updated on 02-Dec-2019 558 Views

JavaScript used to be single-threaded. It runs using what is called an event loop.The Event Loop has one simple job — to monitor the Call Stack and the Callback Queue. If the Call Stack is empty, it will take the first event from the queue and will push it to the Call Stack, which effectively runs it.JS in browsers doesn't support multithreading in the event loop as it is not needed for 99.999% of the websites. The event loop handles everything seamlessly.For the remaining apps, devs can use web workers. Web Workers are a simple means for web content to ...

Read More

How to test if a letter in a string is uppercase or lowercase using javascript?

Ayush Gupta
Ayush Gupta
Updated on 02-Dec-2019 8K+ Views

To test if a letter in a string is uppercase or lowercase using javascript, you can simply convert the char to its respective case and see the result.Examplefunction checkCase(ch) {    if (!isNaN(ch * 1)){       return 'ch is numeric';    }     else {       if (ch == ch.toUpperCase()) {          return 'upper case';       }       if (ch == ch.toLowerCase()){          return 'lower case';       }    } } console.log(checkCase('a')) console.log(checkCase('A')) console.log(checkCase('1'))OutputThis will give the output −lower case upper case ch is numeric

Read More

What Is a JavaScript Framework?

Ayush Gupta
Ayush Gupta
Updated on 02-Dec-2019 1K+ Views

JS frameworks are JavaScript code libraries that have pre-written code to use for routine programming features and tasks. It is literally a framework to build websites or web applications around.For example, in plain JS, you have to manually update the DOM using DOM APIs for setting styles updating content, etc.JS frameworks can help automate this repetitive task using features like 2-way binding and templating.Frameworks have their own way of doing things. For example, Angular is a popular JS framework that comes with many features like dependency injection, routing, etc and has its own way of building an application using it. ...

Read More
Showing 351–360 of 433 articles
« Prev 1 34 35 36 37 38 44 Next »
Advertisements