Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

json-parsejson-stringifyx-purpose

It's a way of cloning an object, so that you get a complete copy that is unique but has the same properties as the cloned object.

var defaultParams = { a : 'b' };
var params = JSON.parse(JSON.stringify(defaultParams));

console.log( params.a ); // b
console.log( defaultParams.a ); // b
console.log( params === defaultParams ); // false
The above outputs false because even though both objects have the a property, with the value b, there are different objects that are independent of each other (they don't refer to the same reference).

The JSON method will only work with basic properties - no functions or methods.
Comment

PREVIOUS NEXT
Code Example
Javascript :: url builder angularjs 
Javascript :: scope hierarchy in angularjs 
Javascript :: component not registered correctly 
Javascript :: express js jump to above directory 
Javascript :: && in react jsx 
Javascript :: check before element jquery 
Javascript :: browserify call bundeled function 
Javascript :: %20find%20all%20docs%20that%20have%20at%20least%20two%20name%20array%20elements_ 
Javascript :: bar code react native 
Javascript :: regular expression 010+100 answer 
Javascript :: validate date 
Javascript :: Coin toss with JavaScript and HTML 
Javascript :: js painting app 
Javascript :: jpa ms sql json data type 
Javascript :: window.getselection outside 
Javascript :: outline none react native web 
Javascript :: socket mock 
Javascript :: maximum element in an array javascript 
Javascript :: TypeError: t is not a function React 
Javascript :: can i use pipe in switch statement javascript 
Javascript :: agora token Renewal 
Javascript :: runjs 
Javascript :: how to go back old tab closing new tab in js 
Javascript :: regex match only letters and numbers 
Javascript :: convert componentDidUpdate into useEffect 
Javascript :: detect finishing write react input 
Javascript :: node mongodb select collection 
Javascript :: nodejs app.on connection 
Javascript :: acender lampada javascript 
Javascript :: javascript swap 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =