Zum Hauptinhalt springen
LIVE
CVSS 6.9CVE-2026-137684 | A security flaw has been discovered in eosphoros-ai DB-GPT up to 0.8.3. This affects the function editor_sql_run of the file packages/dbgpt-app/src/dbgpt_app/openapi/api_v1/editor/api_editor_v1.py of the component Editor SQL Run API. Performing a manipulation of the argument db_name results in authorization bypass. It is possible to initiate the attack remotely. The exploit has been released to the public and may be used for attacks. The pull request to fixCVSS 8.7CVE-2026-137992 | libexpat through 2.11.0 contains a denial of service vulnerability in defineAttribute() of lib/xmlparse.c that fails to detect duplicate non-ID #IMPLIED or #REQUIRED attribute declarations. Attackers can supply a crafted XML document with repeated ATTLIST declarations in an internal DTD subset to cause quadratic CPU consumption in storeAtts() during parsing.CVSS 8.5CVE-2026-137994 | Leo through 6.8.10 contains an insecure deserialization vulnerability that allows attackers to execute code by embedding pickled data in unknown XML attributes of .leo outlines. Attackers can place a pickle __reduce__ gadget in a or element attribute that resolveUa passes to pickle.loads, executing code with user privileges when the outline is opened.CVSS 7.0CVE-2026-137995 | FOG Project before 1.6.0.119 contains an information disclosure vulnerability that allows unauthenticated attackers to obtain host tokens from status/hostgetkey.php by supplying a host MAC address. Attackers can present the token to service/hostinfo.php to retrieve decrypted Active Directory join credentials and Windows product keys during deployment windows.CVSS 6.8CVE-2026-137996 | Zettlr before 4.11.0 fails to validate URI schemes in Markdown link targets, allowing attackers to launch arbitrary registered protocol handlers via Electron shell.openExternal without confirmation. Attackers can craft documents whose Ctrl/Cmd-clicked links use smb:// to leak NTLM credential hashes on Windows or invoke custom protocol handlers with attacker-controlled parameters.CVSS 8.5CVE-2026-137997 | HCIPy through 0.7.1 contains an insecure deserialization vulnerability that allows attackers to execute code by supplying crafted .pkl files to read_field, read_grid or read_mode_basis. Because hcipy/util/io.py selects pickle by file extension and calls pickle.load, a __reduce__ gadget in a pupil, apodizer, PSF or mode-basis file runs code with the user's privileges.CVSS 8.5CVE-2026-137998 | Detoxify 0.5.3 through 0.5.4 contains an insecure deserialization vulnerability in load_checkpoint that allows attackers to execute code by supplying a crafted checkpoint file. Attackers can embed a pickle __reduce__ gadget in a .ckpt file loaded via torch.load with weights_only=False to run code with the user's privileges.CVSS 8.5CVE-2026-137999 | JSONSchema2PoPo2 through 3.0.3 contains a code injection vulnerability that allows attackers to inject Python code by supplying JSON Schema default or format values that are written unescaped. Attackers can place a single quote in a string property default to break out of the literal in the generated __init__ signature, executing injected code when the generated module is imported.
Alle im Drawer
Intelligence View
⚡ tsecurity.de Intelligence

Shallow Copy VS Deep Copy In Java Script : Explained in easiest way

What is copying and how does it Work in JS? In JavaScript, Copying is the process of making duplicate of of an existing values like integer, string, objects…

Beitrag
0
Seite
0
↗ Quelle (dev.to)
Quelle & Fakten · 5 Min. Lesezeit
Quelle: dev.to
Rubrik: Secure Programming




What is copying and how does it Work in JS?



In JavaScript, Copying is the process of making duplicate of of an existing values like integer, string, objects and function.

However this is not so easy and straightforward as it looks. It all depends upon either you are copying primitive data types or non-primitive data types. If you are copying a primitive data type then it would be working with primary value but in the case of non-primitive data types it work with referenced values.



Lets see how it works with primary value and the referenced values





Primitive Value (Copy By Value)



For primitive data types, there it is copy by value.

Let me show this to you with the help of an example in code block by just simply declaring an integer "a" and copying its value in another integer "b".




let a = 10;
let b = a; // Copying the value

b = 20; // Changing b does NOT affect a
console.log(a); // Output: 10






You can see that changing value of b does not affecting a. This all happens because JavaScript creates a completely new independent copy of the actual values in the memory.



On other hand primitive data types consist of integers, boolean values,strings, symbols, bigInt and null.






Non-Primitive Value (Copy By Reference)



For non- primitive data types, there it is copy by reference.

Let it make clear with example of non-primitive data type object.




let original = { name: "YOO" };
let copy = original; // Copying the reference!

copy.name = "NEW";

console.log(original.name); // "NEW" -> Oops! The original changed too.







In above code block there it is a object name original that is stored somewhere in memory, and variable hold a pointer(reference) to that location.

If you are copying the variable you are just copying the pointer, not the actual referenced value.

So, when you are changing the value in copied item it will change the actual value in it.






To solve this problem here comes the concept of Shallow Copy and Deep Copy:



Here comes the golden rule to understand the difference between shallow copy and deep copy.





  • A shallow copy copies the references.

  • A deep copy copies the values.




Its simple, let break it through analogy of pizza :



-- > For shallow copy it is same as you and your friend is sharing a same pizza. Whenever you and your friend eats pizza it shrinks.



-- > For deep copy it is like you both owns different pizza. If your friend eats a slice, his pizza gets shrinks your remains untouched and same goes with your friend's pizza when you eats your pizza, his pizza remains untouched.



And that's it , this is full concept that revolves around shallow copy and deep copy.

Now lets get it through some examples of javascript.









Shallow Copy in JavaScript:



A shallow copy duplicates the top level of values. If there are some nested values it still copies it but only the referenced values.





  • Using Spread Operator(...) -
    This is one of the most common techniques used to make shallow copy in JavaScript.




let original = { name: "YOO",
age: 22,
gender: "Male"
}; // Original named object.

let copyOriginal = { ...original} // making a shallow copy of original named object using spread operator.

console.log(copyOriginal.name) // Output --> YOO






But there is A Shallow trap, whenever it comes a nested values and copying through spread operator those nested values will share exactly same references. So changing these referenced values will also lead to the changes in actual values.



To solve this problem here comes the concept of Deep Copy, lets learn this through some examples of javaScript.






Deep Copy In JavaScript:



Deep Copy in JavaScript creates a differently new object to copy the actual values. Changes done in values of new copied objects are not displayed in the actual values.

Let us see some methods to create a deep copy in JavaScript.





  • Using built in function structuredClone() :
    StructuredClone() is a built in javaScript function that is available in all modern day browser and Node.js. It handles deep nested structure perfectly. It is built into the runtime(browser and node.js) and handles most complex data types smoothly.




let Teas = {            // Create a object named as tea with some values inside it
name: "Lemon tea",
caffine: "No",
tasty: "Yes"
}

let newTeas = structuredClone(Teas); // Creating a deep copy of teas using structured clone method

newTeas.name = "Mango Tea";
console.log(Teas); //Output --> { name: 'Lemon tea', caffine: 'No', tasty: 'Yes' }
console.log(newTeas); //Output --> { name: 'Mango Tea', caffine: 'No', tasty: 'Yes' }






PROS AND CONS




  • Pros is that it is fast, native and correctly handles Date ,RegExp ,maps and circular references.

  • Cons is that it is will throw error when an object contain function or DOM nodes.








  • Using JSON.parse(JSON.stringify()):
    Before structuredClone() developers uses this trick to create a deep copy of object. It converts the object into a JSON string, then parse it back into brand-new object.




const original = { name: "Yo!!", nested: { id: 12 } };

const clone = JSON.parse(JSON.stringify(original));






Why we should not use it?

The method strips out the data type that are not supported by JSON. IF your object contains date , undefined , Null, Map, Set , or Infinity, they would either be lost or may be get corrupted or the value can be converted to NULL.






This is all about Deep Copy and Shallow Copy. Hope this gets you how and when to use shallow and deep copy method. JavaScript is full of such twist and turns.

Information ergänzen Fachhinweis, Update, Korrektur oder Quelle zur Meldung beitragen
Gäste-Hinweise werden kurz redaktionell geprüft und danach hier angezeigt.

Community-Hinweise zur Meldung

0 freigegeben
Social ReaktionenReagiere als Erste:r — dein Feedback zählt!
Informations-Bewertung:

💬 Community discussion & comments

🌐 Join the main chat

Start the discussion in the Social Chat broadcast stream or submit an expert contribution via the supplement form above.

Community Rating & Social Proof
⭐ Reader Rating
–
Ø / 5.0
No reader ratings yet
Was this article helpful?
0
Submit your rating
Detailed rating (optional)
Content & Quality
Source & Credibility
Freshness
Security Briefing Free · 1-Click Unsubscribe

Intelligence Digest — free

The top security news daily · unsubscribe anytime

Related story clusters & sources (vector AI)

2 Cluster
2 sources
OpenAI counter-sues Apple over trade secret theft
AppleInsider News 1 hour ago
1 more source
Similar posts
🔍 Verwandte News

Auch interessante Nachrichten Shallow Copy VS Deep Copy In Java Script : Explained in easiest way

Thematisch verwandte Begriffe: Shallow, Copy, Deep, Java · 6 Treffer

Laden...

Loading posts ...

Laden...

Loading videos ...

Laden...

Loading posts ...

Laden...

Loading videos ...

Laden...

Loading posts ...

Laden...

Loading videos ...

Laden...

Loading posts ...

Laden...

Loading videos ...

💬 Loading comments…
Pull to refresh
Widgets & Topics
Loading widgets…
Nächster Beitrag