Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

get all keys of object in javascript

myObject = {
	"key": "value",
    "key2":"value2"
}
Object.keys(myObject);
//console.log(Object.keys(myObject))   = ["key", "key2"]
Comment

js get all object keys

  for (let key in object) {
    console.log(key);
    console.log(object[key]);
  }
Comment

get all keys from pbject javascirpt

const object1 = {
  a: 'somestring',
  b: 42,
  c: false
};

console.log(Object.keys(object1)); // expected output: Array ["a", "b", "c"]

// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys
Comment

get all keys in js

let data = {
  rules: [
    {
      host: "node-microservice.local",
      http: {
        paths: [
          {
            pathType: "Prefix",
            path: "/",
            backend: {
              service: {
                name: "proxy",
                port: {
                  number: 80
                }
              }
            }
          }
        ]
      }
    },
    {
      host: "node-microservice.local",
      http: {
        paths: [
          {
            pathType: "Prefix",
            path: "/",
            backend: {
              service: {
                name: "proxy",
                port: {
                  number: 80
                }
              }
            }
          }
        ]
      }
    }
  ]
}


function getAllKeys(obj){
  let res = []
  function getKeys(obj){
    for(let key in obj){
      res.push(key);
      if(typeof obj[key] === "object"){
        getKeys(obj[key])
      }
      
    }
  }
  getKeys(obj);
  return res;
}

let result = getAllKeys(data).filter((data) =>  Number.isNaN(Number(data)))
let newResult = [...new Set(result)]

console.log(newValue)
Comment

PREVIOUS NEXT
Code Example
Javascript :: iframe in angular 
Javascript :: how to remove header in react navigation 
Javascript :: useref object is possibly null 
Javascript :: build palindrome javascript 
Javascript :: javascript letters as number 
Javascript :: js encryption two way 
Javascript :: jquery scroll when object appear on screen make animation 
Javascript :: javascript array insert at 0 
Javascript :: remove array empty values javascript 
Javascript :: js string to date 
Javascript :: javascript object to json string 
Javascript :: require() of ES modules is not supported when importing node-fetch 
Javascript :: javascript alphabet to number 
Javascript :: js timestamp 
Javascript :: get two-digit hex from number javascript 
Javascript :: floating point in javascript 
Javascript :: how to stop iframe video using javascript 
Javascript :: jsconfig.json vue 
Javascript :: check if number is negative javascript 
Javascript :: javascript print all items in array 
Javascript :: html javascript redirect 
Javascript :: pick random value from array 
Javascript :: function expression and function declaration 
Javascript :: datetime to date in js 
Javascript :: jquery get document scrolltop 
Javascript :: get file name nodejs 
Javascript :: json schema array of objects 
Javascript :: react redux wait for props 
Javascript :: number format in javascript 
Javascript :: extract number from string 
ADD CONTENT
Topic
Content
Source link
Name
3+6 =