How to create a null-filled array without [], comma, or the word “Array”

const praiseBeToCthulhu = (len) => {
const obj = { a: ‘”‘ }
obj.b = ”

const codepoints = JSON.stringify(obj).split(”)
.map(ch => ch.codePointAt())

const grab = (n) => codepoints.slice(n).shift()

const x = grab…


This content originally appeared on DEV Community and was authored by lionel-rowe

const praiseBeToCthulhu = (len) => {
    const obj = { a: '"' }
    obj.b = ''

    const codepoints = JSON.stringify(obj).split('')
        .map(ch => ch.codePointAt())

    const grab = (n) => codepoints.slice(n).shift()

    const x = grab(6)
    const y = grab(9)

    let s = String.fromCharCode(x - 1)

    for (let i = 0; i < len; ++i) {
        s += Object.getPrototypeOf(
            Object.getPrototypeOf(
                Object.getPrototypeOf(
                    Object
                )
            )
        )
        s += String.fromCharCode(y)
    }

    if (s.length > 1) {
        const z = s.split('')
        z.pop()

        s = z.join('')
    }

    s += String.fromCharCode(x + 1)

    return JSON.parse(s)
}

OK, there are definitely more concise ways, but hey, maybe you're getting paid by the number of lines of code you write.

Thank-you for coming to my TED talk. 🙇‍♀️


This content originally appeared on DEV Community and was authored by lionel-rowe


Print Share Comment Cite Upload Translate Updates
APA

lionel-rowe | Sciencx (2022-01-05T07:45:22+00:00) How to create a null-filled array without [], comma, or the word “Array”. Retrieved from https://www.scien.cx/2022/01/05/how-to-create-a-null-filled-array-without-comma-or-the-word-array/

MLA
" » How to create a null-filled array without [], comma, or the word “Array”." lionel-rowe | Sciencx - Wednesday January 5, 2022, https://www.scien.cx/2022/01/05/how-to-create-a-null-filled-array-without-comma-or-the-word-array/
HARVARD
lionel-rowe | Sciencx Wednesday January 5, 2022 » How to create a null-filled array without [], comma, or the word “Array”., viewed ,<https://www.scien.cx/2022/01/05/how-to-create-a-null-filled-array-without-comma-or-the-word-array/>
VANCOUVER
lionel-rowe | Sciencx - » How to create a null-filled array without [], comma, or the word “Array”. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/01/05/how-to-create-a-null-filled-array-without-comma-or-the-word-array/
CHICAGO
" » How to create a null-filled array without [], comma, or the word “Array”." lionel-rowe | Sciencx - Accessed . https://www.scien.cx/2022/01/05/how-to-create-a-null-filled-array-without-comma-or-the-word-array/
IEEE
" » How to create a null-filled array without [], comma, or the word “Array”." lionel-rowe | Sciencx [Online]. Available: https://www.scien.cx/2022/01/05/how-to-create-a-null-filled-array-without-comma-or-the-word-array/. [Accessed: ]
rf:citation
» How to create a null-filled array without [], comma, or the word “Array” | lionel-rowe | Sciencx | https://www.scien.cx/2022/01/05/how-to-create-a-null-filled-array-without-comma-or-the-word-array/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.