Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

JavaScript Extract from Object and Array

const data = {
    "Name": "John Doe",
    "Age": 99,
    "Gender": "m",
    "Childs": ["Max", "Anna", "Phil"]
}

// Properties with Variablename = Propertyname
var { Name, Age, Gender } = data;
console.log(Name + " is " + Age + "Year old.");

// Properties with custom Variablename
var { Name: n } = data;
console.log(n);

// Extract Array
var { Childs } = data;
console.log(Childs);

// Extract from Array
var [child1, child2, child3] = Childs;
console.log("First: " + child1 + ", Second: " + child2, ", Third: " + child3);
Comment

javascript extract array from object

var obj = {v1: 'v1', v2: 'v2'};
// extract object's values as array
var valuesArray = Object.values(obj);	// ['v1','v2']
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript numbers 
Javascript :: Multiple functions in javascript onclick 
Javascript :: vue sidebar 
Javascript :: js string 
Javascript :: vue js laravel tutorial 
Javascript :: type js 
Javascript :: Set CSS styles with javascript 
Javascript :: in js pass infinite argument in function 
Javascript :: How to acces props of a functional component 
Javascript :: setting up react on visual studio code 
Javascript :: name function in javascript 
Javascript :: mvc asp.net partial view from js 
Javascript :: adding pre tag javascript 
Javascript :: javascript remove an element from an array 
Javascript :: keyboard close when typing react native 
Javascript :: context menus use 
Javascript :: assign values to array in javascript 
Javascript :: disable a function javascript 
Javascript :: for in in javascript 
Javascript :: code cat 
Javascript :: discord.js command cooldown 
Javascript :: sort array with negative numbers 
Javascript :: javascript double exclamation mark 
Javascript :: render and mount functional component 
Javascript :: js xor 
Javascript :: dynamodb async await 
Javascript :: Looping arrays with for loop 
Javascript :: macam macam looping javascript 
Javascript :: what is the use of consrtructors in reactjs 
Python :: ipython autoreload 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =