Javascript Articles - Page 374 of 534

Difference between JSON and XML

Mahesh Parahar
Updated on 24-Feb-2020 08:08:04

418 Views

Both JSON and XML are the most popular data transversal resources in programming world.Due to their various important characteristics and features both of these resources are widely used globally.On the basis of their features following are the important differences JSON and XMLSr. No.KeyJSONXML1AbbreviationJSON stands for JavaScript Object Notation.On other hand XML stands for Extensible Mark-up Language.2TypeJSON format is data interchangeable.On other hand XML format is Mark-up language.3Based onJSON is derived from JavaScript language from where it puts the feature to represents the data in a way of representing objects.On other hand XML is derived from SGML and uses tag structure ... Read More

JavaScript symbol.description property

AmitDiwan
Updated on 17-Dec-2019 11:03:49

138 Views

The symbol.description property in JavaScript converts a Symbol object to a primitive value. The syntax is as follows −Symbol()[Symbol.toPrimitive](hint);Example Live Demo Demo Heading Click to display... Result    function display() {       const val = Symbol('john');       console.log(val[Symbol.toPrimitive]);    } OutputClick the “Result” button −Example Live Demo Demo Heading Click to display... Result    function display() {       const val = Symbol(2465);       var res = val[Symbol.toPrimitive](99);       console.log(res)    } OutputClick the “Result” button and get the result in Console −

Object literals vs constructors in JavaScript

Aman Kumar
Updated on 19-Dec-2022 12:23:29

1K+ Views

Object literals and constructors both are used to create an Object in JavaScript. An object created by the object literals is a singleton. This means when a change is made to the object, it affects that object across the entire script. If an object created by a function constructor has multiple instances of the object. This means the changes made to one instance, will not affect other instances. Object Literal Notation − Let’s create user details where we have the key, name, age, and name of the company. So we are creating an object named userDetails. const userDetails = {name: "Aman", ... Read More

How to clone a js object except for one key in javascript?

Aman Kumar
Updated on 19-Dec-2022 12:21:28

2K+ Views

In computer programming, cloning refers to an object copied by a method or copy factory function often called clone and copy. The easiest way to clone an object except for one key would be to clone the whole object and then remove the property that is not required. Cloning, however, can be of 2 types − Deep Clone Shallow Clone Shallow Clone The shallow clone copies as little as possible. For example, a shallow copy of a collection might be a copy of the collection’s structure, not its elements. With a shallow copy, two collections now share individual ... Read More

Jasmine.js comparing arrays

Ayush Gupta
Updated on 02-Dec-2019 06:55:34

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

Converting a string to a date in JavaScript

Aman Kumar
Updated on 19-Dec-2022 12:11:06

4K+ Views

In this article, we are going to discuss how to convert a string value to a Date object in JavaScript. There are two ways to achieve this − Using the constructor of the Date class − This constructor accepts a string value representing the date value, converts it into a Date object, and returns the result. Using the Date.parse() method − Same as the Date constructor this method accepts a string value parses and returns the date value in the form of milliseconds. Let us see these solutions with examples − Using the Date() constructor The most commonly used way ... Read More

Inserting string at position x of another string using Javascript

Aman Kumar
Updated on 19-Dec-2022 12:07:26

1K+ Views

In this article, you are going to learn how to insert a string at a position in another string. JavaScript does not give a direct way to achieve this. For this, we can use the slice method. The slice method extracts a section of a string and returns a new string. In addition to the slice() method we can also use the methods join() and substr(). Using the slice() Method of the String class This slice() method gets parts of the string and returns the extracted part from the string and makes a new string. Following is the syntax ... Read More

How to Clear the JavaScript Console in Google Chrome

Aman Kumar
Updated on 19-Dec-2022 12:05:07

16K+ Views

In this article we are going to learn how to clear the JavaScript Console in Google Chrome. We have various methods to clear the console; but our question is why do we need to clear the console? Sometimes we have lots of commands and logs printed in any browser console which makes it look substandard and packed with output. So, we need to clear the console. And there are multiple ways to clear the console of google chrome. Using the console.clear() method This method will clear the console and display the message on the console that the console was clear. ... Read More

Dynamically creating keys in JavaScript associative array

Aman Kumar
Updated on 19-Dec-2022 12:01:59

4K+ Views

In this article, we are going to discuss how to create keys in a JavaScript associative array dynamically. Associative arrays are dynamic objects that are user defined as needed. When you assign values to keys in a variable of types array, then the array is transformed into an object, and it loses the attributes and methods or array. i.e. the length attributes have no effect because the variables are no longer of the type array. JavaScript associative arrays are same as any other literals. You can add keys to these using the square brackets notation you can add keys to ... Read More

Why Ember.js is the best javascript frame work?

Aman Kumar
Updated on 19-Dec-2022 11:58:06

277 Views

Ember.js is the best framework. The user of Ember.js is increasing day by day. The popularity of ember.js is 6.3% of JavaScript developers currently using ember. Its popularity has stood over the last two years. Ranked 4th most popular JavaScript framework. Ember.js is an MVVM (Model−view−view−model) model framework for complex and multiple-page applications and it is an open-source framework. It is a very redefined control system that helps you to integrate with the new version without any problems. Ember.js is a free javascript client-side framework it is used for developing web applications. It is providing the complete solution which contains ... Read More

Advertisements