Vineeth.mariserla has Published 270 Answers

How to delete a property of an object in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 29-Jun-2020 11:49:20

To delete a property of an object, delete key word should be used. Delete key word can be used with both the methods such as Dot method and Bracket method.syntaxdelete object.property;ExampleIn the following example initially when the property "country" is executed its value "England" is displayed in the output. But when that ... Read More

How to convert a string in to date object in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 29-Jun-2020 11:48:18

To convert a string in to date object Date() method should be used. This method creates a date instance that represents a single moment in time in a platform-independent format.ExampleIn the following example a string named "str" is initially parsed using JSON.parse() method and then converted in to date object ... Read More

What is the difference between instanceof() and Array.isArray() methods in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 29-Jun-2020 11:44:13

Array.isArray() method is universal, it can function any where whereas instanceof operator is not universal, it can't work in new environment..syntax-1Array.isArray(array);syntax-2array instance of Array;In the following example, where there is no new environment created, both Array.isArrar() and instanceof have produced same output.ExampleLive Demo<html> <body> <script>    var a = [1, 2, ... Read More

How to access nested json objects in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 29-Jun-2020 11:42:50

Accessing nested json objects is just like accessing nested arrays. Nested objects are the objects that are inside an another object.In the following example 'vehicles' is a object which is inside a main object called 'person'. Using dot notation the nested objects' property(car) is accessed.Example-1Live Demo<html> <body> <script>    var person ... Read More

What is the use of Object.isFrozen() method in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 29-Jun-2020 11:36:06

Object.isFrozen()Object.isFrozen() method is used to find whether an object is frozen or not. An object is frozen if it followed the below criteriaIt should not be extensible.Its properties should be non-configurable.It shouldn't accept any new properties.SyntaxObject.isFrozen(obj);Parameters - Object.isFrozen() accepts an object as a parameter and scrutinizes whether it is frozen or not and ... Read More

How many ways can a property of a JavaScript object be accessed?

vineeth.mariserla

vineeth.mariserla

Updated on 29-Jun-2020 11:33:58

 An object property can be accessed in two ways. One is .property and the other is [property].Syntax-1Object.property;Syntax-2Object["property"];For better understanding, lets' look at the following example.In the following example an object called 'person' is defined and its properties were accessed in a dot notation.ExampleLive Demo<html> <body> <script> var person = { ... Read More

How to check whether an array is a true array in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 29-Jun-2020 11:28:55

In javascript, arrays are not true arrays. They are javascript objects. So when we try to know their type using typeof() operator the displayed output will be object.Syntaxtypeof(operand);parameters - typeof() operator takes an operand and returns the data type of the operand. In the following example even though variable 'a' is an ... Read More

What is a pure function in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 29-Jun-2020 11:27:32

Pure functionA pure function is a deterministic function. This means when a same input is passed every time, the function will return same output. In mathematical terms it is nothing but a well defined function.A pure function will have the following propertiesIt depends only on its own arguments.It wont try to ... Read More

How to know whether an object is sealed or not in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 29-Jun-2020 11:19:30

Object.isSealed() is the method used to find whether an object is sealed or not in javascript. This method gives out boolean output. An object is sealed if the following conditions hold true.1) It should not be extensible.2) its properties should be non-configurable.SyntaxObject.isSealed(obj)Arguments -  Object.isSealed() takes an object as a parameter and ... Read More

How to add two strings with a space in first string in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 29-Jun-2020 11:10:23

To add two strings we need a '+' operator to create some space between the strings, but when the first string itself has a space with in it, there is no need to assign space explicitly. In the following example since the string 'str1' has a space with in it, just ... Read More

Previous 1 ... 6 7 8 9 10 11 12 ... 27 Next
Advertisements