[removed] Getting a Single Property Name

前端 未结 5 1674
耶瑟儿~
耶瑟儿~ 2020-12-19 20:51

Given an object like this:

{ name: \"joe\" }

I want to get the value \"name\". I know I can use the for construct to iterate over the prope

5条回答
  •  [愿得一人]
    2020-12-19 21:25

    This seems to be about the best you can get:

    function myFunc(v) {
      for (var x in v) { return { prop: x, val: v[x] }; }
      return null;
    };
    

提交回复
热议问题