Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Front End Technology Articles - Page 507 of 860
15K+ Views
Enums or Enumerated types are special data types that set variables as a set of predefined constants. In other languages enumerated data types are provided to use in this application. Javascript does not have enum types directly in it, but we can implement similar types like enums through javascript. In this article, we shall cover the syntaxes and uses to define enumerated types in javascript. Below the syntax is given to show a basic implementation of enums in javascript, we can define an object to encapsulate the enumerated type, and assign keys for each enum value. Syntax const EnumType ... Read More
799 Views
Sometimes we perform certain tasks in any language by maintaining a time delay. For instance, we are making a timer application that will update each second. In such cases, we wait for a second and update the second timer one by one. We also call this delay or sleep().In some other languages like Java, there is a sleep() function that is used to wait for some time. In this article, we shall see what is the equivalent method of sleep in javascript. Let us follow the syntaxes for delay generation Syntax (Defining a function) function sleep(t: the time in ... Read More
4K+ Views
To declare a variable in javascript we can use var, let or const keyword. Earlier var was only way to declare variable in javascript.In ES6, let and const keywords were introduced as a better way to declare variables. Now it is advised to use let instead of var to declare a variable. In this article we will be understanding the differences between var and let in Javascript. We will be differentiating between let and var based on the features mentioned in the table: ... Read More
974 Views
Java Script Object Notation is one of the many standard formats to store data in different many applications. JavaScript objects can also be stored in a file in this JSON format. In this article, we will cover a few methods to print the JSON objects in a pretty method. Let us see this as an example. We are creating an object in javascript before − Example (Creating Javascript Object)
2K+ Views
Javascript asynchronous programming uses a promise object which does not block the execution of the current flow but informs the compiler that there is something that is not completed yet, and whenever it completes it returns a signal to the system. There are mainly two possibilities. Either the promise object will complete successfully, or it will stop by returning an exception. To handle exceptions coming from promise objects the catch() methods are used. In try-catch methods also we can use another block named ‘finally’. This will execute no matter what is done previously. For promises also we can use the ... Read More
453 Views
Asynchronous programming is fairly common in javascript network programming. In this approach, we can download, or perform some time-dependent jobs without locking thecurrent execution flow. Which performs asynchronously as compared to our program, which can be done using async functions in javascript. In this article, we will discuss the techniques to return the response from an asynchronous call in javascript. Before entering into the concept, let us see in which cases it becomes confusing to developers when asynchronous execution calls are taken into action. Let us see the following situation. Syntax function aTrivialFunction() { ajaxCall(..., function onSuccess(result) ... Read More
245 Views
JavaScript classes, introduced in ES6, are syntactical sugar over JavaScript prototype-based inheritance. Classes are in fact "special functions". You can define classes in JavaScript using the class keyword using the following syntax −class Person { // Constructor for this class constructor(name) { this.name = name; } // an instance method on this class displayName() { console.log(this.name) } }This is essentially equivalent to the following declaration −let Person = function(name) { this.name = name; } Person.prototype.displayName = function() { console.log(this.name) }This class can also be written as ... Read More
3K+ Views
Multiple-inheritance is not supported by Javascript by default. But sometimes we need to mix multiple object properties into a single object. Object property sharing can be done using mixins. In this article, we shall cover what are mixins in JavaScript. The definition of mixins can be stated as mixins is a class that contains methods that can be used by other classes without inheriting from that class. The methods in mixin provide certain behavior which is not used alone but can be used to add these behaviors to other classes. Mixin: A Simple Example See the following example where we ... Read More
253 Views
The \W metacharacter is used to find a non-word character.A word character is a character from a-z, A-Z, 0-9, including the _ (underscore) character.Example// Containing any non word character: console.log(/\W/.test(" ")) console.log(/\W/.test(".!@#")) // Not containing non word characters: console.log(/\W/.test("a")) console.log(/\W/.test("B")) console.log(/\W/.test("9")) console.log(/\W/.test("_"))Outputtrue true false false false false
141 Views
The \s metacharacter is used to find a whitespace character.A whitespace character can be −A space characterA tab characterA carriage return characterA new line characterA vertical tab characterA form feed characterExample// Not containing any white spaces: console.log(/\s/.test("1")) console.log(/\s/.test("test")) // Containing whitespace characters: console.log(/\s/.test(" ")) console.log(/\s/.test("a\tb")) console.log(/\s/.test("mn"))Outputfalse false true true true