Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 从数组中的数组中删除元素_Javascript_Arrays_Reactjs_React Native - Fatal编程技术网

Javascript 从数组中的数组中删除元素

Javascript 从数组中的数组中删除元素,javascript,arrays,reactjs,react-native,Javascript,Arrays,Reactjs,React Native,****************更新********************************************************* 我在数组下有一个数组: 我想从type=“tag”和name=“style”所在的子数组中删除一个元素。子数组是下面打印的对象数组中的数组 我的目标也是保持对象的原始数组完好无损 我正在使用以下代码,但它给了我未定义的代码: // ARRAY of Objects const responseText = html.parse(business

****************更新*********************************************************

我在数组下有一个数组:

我想从type=“tag”和name=“style”所在的子数组中删除一个元素。子数组是下面打印的对象数组中的数组

我的目标也是保持对象的原始数组完好无损

我正在使用以下代码,但它给了我未定义的代码:

// ARRAY of Objects
const responseText = html.parse(businessResponseText);


console.log('responseText',responseText);

// Needs work ---- how do I transform this original object?
const transformedObject = {
...responseText, 
children: responseText.map((children)=>{
  children.children.filter(
    el => el.type !== "tag" && el.name !== "style" 
)
})
}

log('transformedobject',transformedobject)

这是我得到的输出:原始vs转换


复制并粘贴代码片段,因为其他人很容易尝试它。让世界变得更美好!;)


复制并粘贴代码段,因为其他人很容易尝试它。让世界变得更美好!;)


你能发布可读的例子而不是截图吗?返回未定义的
。你在找吗?你能发布可读的例子而不是截图吗?返回未定义的
。你在找吗?我得到了一个数组,但是其余的数据都被修改了。我需要原始对象完好无损,只有子数组中的标记和样式。你只是想从嵌套的子对象中删除“type”和“name”属性吗?您可以共享预期的输出吗?我只想从子数组中删除该对象,其中type==tag and name==style更新我的原始帖子。我得到了一个数组,但其余的数据被更改。我需要原始对象完好无损,只有children数组中的标记和样式正确。您只想删除“type”和“name”吗从嵌套的子对象中删除属性?您可以共享预期的输出吗?我只想从子数组中删除该对象,其中type==标记,name==样式更新我的原始帖子。您好,您可以重新查看帖子吗?我需要更改objectsNo数组中的子数组问题!很乐意帮忙!嗨,你能重新回顾一下这个帖子吗?我需要更改objectsNo数组中的子数组问题!很乐意帮忙!
const transformedList = styleFree.map(obj => ({
    ...obj, 
    children: obj.children.filter(
        el => el.type !== "tag" && el.name !== "style" 
    )
})
stylefree = stylefree.map((children) => {
    children.children = children.children.filter((nested)=>{
        return (nested.type!="tag" && nested.name!="style");
    });
    return children;
});