D3.js node.children Property

The node.children property in D3.js returns an array of child nodes (null for leaf nodes and undefined for nodes having no child).
Syntax:
node.children
Return Value: This property returns an array of child nodes (null for leaf nodes and undefined for nodes having no child).
Example 1:
HTML
| <!DOCTYPE html> <html> <head>     <metacharset="utf-8">  Â    <scriptsrc=     </script> </head>  Â<body>     <script>         var data = {             "name":"zambiatek",              "about":"Computer Science Portal",             "children":[{"name":"GFG"}]         }         var root = d3.hierarchy(data);         console.log(root.children);     </script> </body>  Â</html> | 
Output:
Example 2: In this example, this method returns undefined as the root node has no child node.
HTML
| <!DOCTYPE html> <html>  Â<head>     <metacharset="utf-8">  Â    <scriptsrc=     </script> </head>  Â<body>     <script>         var data = {"name":"GFG1"}  Â        var root = d3.hierarchy(data);  Â        console.log(root.children);     </script> </body>  Â</html> | 
Output:
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, zambiatek Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
 
				 
					



