
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
Found 6710 Articles for Javascript

569 Views
"this" keyword in an arrow functionThe JavaScript 'this' keyword refers to the object it belongs to. In an arrow function, 'this' belongs to a global object. Inside a simple function, there might be chances that 'this' keyword can result in undefined but in an arrow function it results in an exact value.ExampleLive Demo function Student(fname, grade) { this.fname = fname; this.grade = grade; this.details = function() { return () => { document.write(`Hi, I'm ${this.fname} from ${this.grade} grade`); }; } } let info = new Student('picaso', 'seventh'); let printInfo = info.details(); printInfo(); OutputHi, I'm picaso from seventh grade

644 Views
In this article we are going to discuss how to convert JavaScript objects to primitive data types manually with suitables examples in JavaScript. Primitive data types are nothing but a string, number, boolean, etc. To convert objects to primitive data types, javascript has provided some methods such as toString(), toDateString(), valueOf(), etc. Using these methods javascript objects can be easily converted to primitive data types. Using the toString() method This method returns a string value representing the string format of the given object. The syntax to convert a javascript object into a primitive date type (string, in this example) is ... Read More

3K+ Views
In this article we are going to discuss how to convert a JSON string into a JavaScript object with suitables examples in JavaScript. There are two possible ways to convert a JSON string into a Javascript object – eval() and parse(). The usage of eval() method is unsafe and not preferred. It is vulnerabable to hackers. The parse() method is preferred in general anytime. The typical application for JSON is Data transfer to and from a web server. The data that has been sent from a server is always a JSON string. Using JSON.parse(), we can convert the JSON string ... Read More

4K+ Views
In this article we are going to discuss how to convert a value to a number in JavaScript. JavaScript has introduced Number(), parseInt(), parseFloat() methods to convert a value into a number and also we can achieve it by using (+) unary operator. These mentioned methods can convert number strings to numbers and Boolean values to 1's or 0's. Let’s us discuss these above mentioned methods briefly. We’ll discuss the 4 possible ways to convert a value to a number with an example each. Number() parseInt() parseFloat() Unary Opertaor(+) Example 1 The following is an example program to ... Read More

157 Views
Math.asinh() and Math.acosh() functions are used to find the hyperbolic arc-sine and hyperbolic arc-cosine of a number respectively. These functions are static methods of Math, therefore they are always used as Math.asinh() and Math.acosh(), rather than as methods of a math object created.Math.asinh()This method is used to find the hyperbolic arc-sine of a number. It takes a number as a parameter and returns hyperbolic sine value.ExampleLive Demo document.write(Math.asinh(2)); document.write(""); document.write(Math.asinh(7)); Output1.4436354751788103 2.644120761058629Math.acosh()This method is used to find the hyperbolic arc-cosine of a number. It takes a number ... Read More

170 Views
Math.imul( )Unlike other multiplying functions, the Math.imul() function returns the result of the C-like 32-bit multiplication of the two parameters. Its application is very high in projects like Emscripten. syntaxvar product = Math.imul(a, b);This method takes two numbers and gives out their multiplication value.Example-1In the following example, two normal integers were given as parameters to the method Math.Imul() and the obtained result is displayed as shown in the output.Live Demo document.write(Math.imul(3, 4)); document.write(""); document.write(Math.imul(-3, 4)); Output12 -12Example-2In the following example, c-like 32-bit values were given as parameters to ... Read More

3K+ Views
In this article we are going to discuss how find the cube root of a number with the help of suitable examples in JavaScript. Using Math object in JavaScript any kind of operation can be done. Math.cbrt(), Math.pow() are the methods especially used to find the cube root of a number and also we can achieve it by using ** operator. It takes a number as a parameter and returns its cube root. To find the cube root of a number in JavaScript, there are three possible ways. The way to do it is by using cbrt() method, second way ... Read More

1K+ Views
The contents of the specified date object are converted into a string using the date.toJSON() function. Applying date() constructor, the date object is generated. Dates describe a particular moment in time. The value of the Date object is described by a string that is returned by the toJSON() function (using toISOString()). In general, this function is programmed to automatically meaningfully serialise Date objects during JSON serialisation. The DateObj is a valid Date object produced by the Date() constructor function, and its data has been transformed into a string. Here are some additional codes for the procedure mentioned below in the ... Read More

212 Views
Symbol.isConcatSpreadableThis well-known symbol is used to configure if an object should be flattened to its array elements when using the Array.prototype.concat() method. If it is false then there is no flattening of the array takes place. By default, the Symbol.IsConcatSpreadable is true. Therefore until and unless it is not declared explicitly flattening of the array can't be avoided.Without SymbolExampleIn the following example, the symbol Symbol.IsConcatSpreadable was doesn't stated explicitly. So by default, the array was flattened as shown in the output. var arr1 = ['mango', 'apple', 'guava']; var arr2 = ['cashew', 'pista', 'bhadham']; ... Read More

163 Views
ES6's template strings is a new way to combine strings. We already have methods such as join(), concat() etc to combine strings but the template strings method is the most sophisticated because it’s more readable, no backslash to escape quotes and no more messy plus operators.Using concat() and join()ExampleIn the following example join() and concat() methods are used to combine strings. If we observe carefully the code looks very messy.Live Demo const platform = 'Tutorix'; const joinMethod = ['The', 'best', 'e-learning', 'platform', 'is', platform].join(' '); document.write(joinMethod); ... Read More