Removing object properties with Lodash

后端 未结 8 1407
旧巷少年郎
旧巷少年郎 2021-02-02 05:30

I have to remove unwanted object properties that do not match my model. How can I achieve it with Lodash?

My model is:

var model = {
   fname: null,
   lna         


        
8条回答
  •  野的像风
    2021-02-02 05:42

    Lodash unset is suitable for removing a few unwanted keys.

    const myObj = {
        keyOne: "hello",
        keyTwo: "world"
    }
    
    unset(myObj, "keyTwo");
    
    console.log(myObj); /// myObj = { keyOne: "hello" }

提交回复
热议问题