anton123 1 年之前
父節點
當前提交
37731dc9ee
共有 1 個文件被更改,包括 0 次插入57 次删除
  1. 0 57
      Рекурсия.js

+ 0 - 57
Рекурсия.js

@@ -161,63 +161,6 @@
 }
 
 
-//Рекурсия : My Stringify
-
-{
-    //let text=''
-    function stringify(parent){
-        let text=''
-        let data 
-        let type
-        if(Array.isArray(parent)){
-            data=[]
-            text+='['
-        }
-        else if(typeof parent === "object" && !Array.isArray(parent) && parent != null){
-            data={}
-            text+='{'
-            type="object"
-        }
-        else{
-           
-            return data=parent
-        }
-        let i = 0
-        for(let el in parent){
-            if(type==="object"){
-                text+= '"'+el+'":'
-            }
-            data[el] = stringify(parent[el])
-            i++
-            
-            if(typeof data[el] === 'number'|| data[el]===null || typeof data[el] === 'boolean'){
-                text+=data[el]+','
-            }
-            else if(typeof data[el] === 'string'){
-                text+='"'+data[el]+'",'
-            }
-            else if(typeof data[el] === 'undefined'){
-                text+= null+','
-            }
-            
-            if(parent.length===i || Object.keys(parent).length===i){
-                text=text.slice(0,-1)
-                type==="object"? text+= '},':text+= '],'
-            }
-
-            
-        }
-        
-        return text.split('}"').join('}').split(']"').join(']').split('"{').join('{').split('"[').join('[').slice(0,-1)
-    }
-
-    const arr  = [1,"string", null, undefined, {a: 15, b: 10, c: [1,2,3,4],d: undefined, e: true }, true, false]
-    const jsonString = stringify(arr) //напишите функцию stringify без использования JSON.stringify
-    console.log(JSON.parse(jsonString)) //не должно поломаться и должно вернуть структуру, во всем схожую с оригинальным arr или table
-}
-
-
-
 //Рекурсия : My Stringify
 {
     function stringify(parent){